home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Apps / MallocDebug.app / English.lproj / Help.nib / data.nib (.txt) < prev   
NeXT TypedStream Data  |  1992-03-03  |  8KB  |  144 lines

  1. typedstream
  2. IBObjectData
  3. Object
  4. CustomObject
  5. WindowManager
  6.     Responder
  7. ScrollView
  8. ClipView
  9. ciifffcfffs
  10. [6855c]{\rtf0\ansi{\fonttbl\f1\fnil Times-Roman;\f0\fswiss Helvetica;}
  11. \margl40
  12. \margr40
  13. {\colortbl;\red0\green0\blue0;}
  14. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f1\b0\i0\ul0\fs36\fc0\cf0 \
  15. Introduction
  16. \fs32 \
  17. \fs28 \
  18. \b MallocDebug
  19. \b0  is a utility for measuring the dynamic memory usage of applications and for finding memory leaks.  You can use 
  20. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  21. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0  to measure all allocated memory in an application, or to measure the memory allocated since a given point in time.  
  22. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  23. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0  also contains a conservative garbage detector that can be used to detect memory leaks.\
  24. \fs36 Preparing your Application\
  25. \fs28 \
  26. To use 
  27. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  28. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0 , you must link your application with a library containing a special version of 
  29. \b malloc
  30. \b0  that will communicate with 
  31. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  32. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0 .  To do this link with the library 
  33. \b /usr/lib/libMallocDebug.a
  34. \b0  using the linker option 
  35. \b -lMallocDebug
  36. \b0 .  The 
  37. \b -lMall
  38. \b0  option must be placed 
  39. \i before
  40. \i0  the 
  41. \b -lsys_s
  42. \b0  option, to ensure that 
  43. \b malloc
  44. \b0  is overridden properly.  If your application is built with the 
  45. \b Interface Builder
  46. \b0 , you can simply add 
  47. \b /usr/lib/MallocDebug.a
  48. \b0  to the 
  49. Other libs
  50.  section of the Project Inspector.\
  51. \fs36 Using 
  52. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  53. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0 \
  54. \fs28 \
  55. To use 
  56. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  57. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0 , you must first select an application to monitor.  The 
  58. \i Open
  59. \i0  menu item in the 
  60. \i Application
  61. \i0  menu brings up the 
  62. \i Select
  63. \i0  panel.  Only applications which you own and which have been configured for use with 
  64. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  65. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0  will appear in the panel.  Select an application by double-clicking its icon, and 
  66. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  67. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0 's application window will appear.\
  68. When the 
  69. \i All
  70. \i0  button is pressed, 
  71. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  72. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0  displays a list of all currently allocated nodes in your application.  These nodes have been allocated by one of the standard C allocation functions (
  73. \b malloc
  74. \b0 , 
  75. \b realloc
  76. \b0 , 
  77. \b calloc
  78. \b0 , or 
  79. \b valloc
  80. \b0 ) or one of NeXT's zone allocation functions (
  81. \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\b\fc1\cf1 NXZoneMalloc
  82. \b0 , 
  83. \b NXZoneRealloc
  84. \b0 , 
  85. \b NXZoneCalloc
  86. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0 ).  Each row displays the zone in which the node was allocated, the address and size of the node and the procedure that allocated the node.  The nodes can be sorted by allocator, by order of al
  87. tion, or by zone.\
  88. \fs36 Damaged Nodes\
  89. \fs28 \
  90. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  91. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0  also detects nodes that have been written to incorrectly.  If your application has written past the end of a node, a right arrow (`>') appears by the node.  Similarly, if your application has written before the start of a node, a left arrow (`<') appears by the node.  Many of these errors are the result of using the result of 
  92. \b strlen(s)
  93. \b0  as the argument to 
  94. \b malloc
  95. \b0  for a string instead of 
  96. \b strlen (s) + 1
  97. \b0 .  Damaged nodes are listed first in all sorting modes.\
  98. \fs36 Finding Memory Leaks\
  99. \fs28 \
  100. To detect memory leaks, 
  101. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  102. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0  contains a 
  103. \i conservative garbage detector
  104. \i0 .\
  105. When the 
  106. \i Leaks
  107. \i0  button is pressed, 
  108. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  109. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0  searches through your program's memory for pointers to each node.  Any node that cannot be referenced is displayed as a memory leak.  Since the garbage detector cannot know which words in memory are pointers, it is possible that an integer has the same value as a pointer to a given node.  In this case that node doesn't show up as a leak, even though it really is.  This is why the garbage detector is called 
  110. \i conservative
  111. \i0 .  In practice, this problem is very rare.\
  112. The second caveat is that the garbage detector only searches for references to the 
  113. \i beginning
  114. \i0  of each node.  If your program doesn't retain a pointer to the start of a node, but instead retains a pointer into the middle of it, that node will show up as a leak even though it really isn't one.\
  115. \fs36 Measuring Memory Usage\
  116. \fs28 \
  117. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  118. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0  can show you the memory usage of a given portion of your program.  To begin measur
  119.  press the 
  120. \i Mark
  121. \i0  button.  After exercising a portion of your program, press the 
  122. \i New
  123. \i0  button to see the nodes allocated since the mark.  Note that 
  124. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  125. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0  always shows you the nodes that are still 
  126. \i currently
  127. \i0  allocated, so you will see only those nodes allocated since the mark that haven't been freed.\
  128. NXCursor
  129. NXImage
  130. NXibeam
  131. Scroller
  132. Control
  133. _doScroller:
  134. @@@ffs
  135. WindowTemplate
  136. iiii***@s@
  137. Panel
  138. File's Owner
  139. ScrollingText
  140.     HelpPanel
  141. IBOutletConnector
  142. IBConnector
  143. window
  144.