home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer) / NeXT_Developer-3.3.iso / NextDeveloper / Apps / MallocDebug.app / English.lproj / Help.nib / data.nib (.txt) < prev   
Encoding:
NeXT TypedStream Data  |  1994-11-29  |  11.3 KB  |  200 lines

  1. typedstream
  2. IBObjectData
  3. Object
  4. CustomObject
  5. WindowManager
  6.     Responder
  7. ClipView
  8. ScrollView
  9. Scroller
  10. Control
  11. _doScroller:
  12. @@@ffs
  13. NXCursor
  14. NXImage
  15. NXibeam
  16. ciifffcfffs
  17. [10756c]{\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f1\fmodern Courier;\f2\fswiss Helvetica;}
  18. \margl40
  19. \margr40
  20. {\colortbl;\red0\green0\blue0;}
  21. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ulnone\fs36\fc0\cf0 \
  22. Introduction
  23. \fs32 \
  24. \fs28 \
  25. \b MallocDebug
  26. \b0  is a utility for measuring the dynamic memory usage of applications and for finding memory leaks.  You can 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  to measure all allocated memory in an application or to measure the memory allocated since a given point in time.  
  29. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  30. \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.\
  31. \fs36 Preparing your Application\
  32. \fs28 \
  33. To use 
  34. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  35. \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 
  36. \b malloc
  37. \b0  that will communicate with 
  38. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  39. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0 .  To do this link with the library 
  40. \b /usr/lib/libMallocDebug.a
  41. \b0  using the linker option 
  42. \b -lMallocDebug
  43. \b0 .  The 
  44. \b -lMallocDebug
  45. \b0  option must be placed 
  46. \i before
  47. \i0  the 
  48. \b -lsys_s
  49. \b0  option, to ensure that 
  50. \b malloc
  51. \b0  is overridden properly.  If your application is built with the 
  52. \b Project Builder
  53. \b0 , you can simply add 
  54. \b MallocDebug.a
  55. \b0  to your application by double-clicking on the Libraries suitcase and selecting it from /usr/lib.\
  56. To prepare your application for tracking which nodes are touched by various operations, use the 
  57. \b mdbsetup
  58. \b0  command line program (see "Viewing Touched Nodes" below).\
  59. \fs36 Using 
  60. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  61. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0 \
  62. \fs28 \
  63. To use 
  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 , you must first select an application to monitor.  The 
  66. \i Open
  67. \i0  menu item in the 
  68. \i Application
  69. \i0  menu brings up the 
  70. \i Select
  71. \i0  panel.  Only currently running applications which you own and which have been configured for use with 
  72. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  73. \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 
  74. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  75. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0 's application window will appear.\
  76. When the 
  77. \i All
  78. \i0  button is pressed, 
  79. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  80. \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 (
  81. \b malloc
  82. \b0 , 
  83. \b realloc
  84. \b0 , 
  85. \b calloc
  86. \b0 , or 
  87. \b valloc
  88. \b0 ) or one of NeXT's zone allocation functions (
  89. \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\b\fc1\cf1 NXZoneMalloc
  90. \b0 , 
  91. \b NXZoneRealloc
  92. \b0 , 
  93. \b NXZoneCalloc
  94. \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 allocation, by zone or by size.\
  95. \fs36 Damaged Nodes\
  96. \fs28 \
  97. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  98. \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, 
  99. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\fc0\cf0 a right arrow (`>') 
  100. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0\cf0 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 
  101. \b strlen(s)
  102. \b0  as the argument to 
  103. \b malloc
  104. \b0  for a string instead of 
  105. \b strlen (s) + 1
  106. \b0 .  Damaged nodes are listed first in all sorting modes.\
  107. \fs36 Finding Memory Leaks\
  108. \fs28 \
  109. To detect memory leaks, 
  110. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  111. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0  contains a 
  112. \i conservative garbage detector
  113. \i0 .\
  114. When the 
  115. \i Leaks
  116. \i0  button is pressed, 
  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  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 
  119. \i conservative
  120. \i0 .  In practice, this problem is very rare.\
  121. The second caveat is that the garbage detector only searches for references to the 
  122. \i beginning
  123. \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.\
  124. \fs36 Measuring Memory Usage\
  125. \fs28 \
  126. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  127. \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 measuring, press the 
  128. \i Mark
  129. \i0  button.  After exercising a portion of your program, press the 
  130. \i New
  131. \i0  button to see the nodes allocated since the mark.  Note that 
  132. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  133. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0  always shows you the nodes that are still 
  134. \i currently
  135. \i0  allocated, so you will see only those nodes allocated since the mark that haven't been freed.\
  136. \fs36 Viewing Touched Nodes\
  137. \fs28 \
  138. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\b\fc1\cf1 MallocDebug
  139. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\b0\fc0\cf0  can show you 
  140. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\fc0\cf0 which nodes are accessed (read or written) by your application
  141. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0\cf0 .
  142. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\fc0\cf0   Knowing which nodes are touched by your application is most useful for tuning the use of different allocation zones, thus improving your program's data locality and minimizing its working set.  To learn more about using zones, look in /NextLibrary/Documentation/NextDev/Concepts/Performance.\
  143. To record which nodes are touched, 
  144. \b MallocDebug
  145. \b0  must place each allocated node from the relevant zones on its own virtual memory page.  Because of this additional memory requirement, you have control over which zones have this per-node monitoring enabled.  After you link your application with 
  146. \b libMallocDebug.a
  147. \b0  (see above), you must run the 
  148. \b mdbsetup
  149. \b0  program on your application to enable per-node monitoring for various zones.  The command\
  150. \f1\fs24     mdbsetup MyApp.app/Myapp -protectable <zone list>\
  151. \f0\fs28 \
  152. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0\cf0 enables the viewing of touched nodes within the zones listed in <zone list>.  The strings "ALL" or "NONE" may also be specified instead of a specific list of zones.\
  153. The command\
  154. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\fc0\cf0 \
  155. \f1\fs24     mdbsetup MyApp.app/Myapp -unprotectable <zone list>\
  156. \f0\fs28 \
  157. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0\cf0 enables the viewing of touched nodes within all zones 
  158. \i except
  159. \i0  those listed in <zone list>.  For examples, specif
  160. \fc1\cf1 ying "
  161. \f1\fs24\fc0\cf0 -unprotectable default ObjC
  162. \f0\fs28\fc1\cf1 " wil
  163. \fc0\cf0 l allow you to see nodes touched in all zones besides the default and Objective-C zones.\
  164. The command\
  165. \pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\fc0\cf0 \
  166. \f1\fs24     mdbsetup MyApp.app/Myapp -print\
  167. \f0\fs28 \
  168. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0\cf0 shows what zones within the application are enabled for touched node viewing.\
  169. After applying 
  170. \b mdbsetup
  171. \b0  to your application, run the application and select it in  
  172. \b MallocDebug
  173. \b0  as described above.  To learn what nodes are touched for a given operation of your application, first press the 
  174. \i Protect
  175. \i0  button.  Then perform the operation in your application.  While you are using the application, 
  176. \b MallocDebug
  177. \b0  records which nodes are touched.  To see this list, press the 
  178. \i Touched
  179. \i0  button.  To see what nodes have not been touched, press the 
  180. \i Untouched
  181. \i0  button.  To stop the recording of touched nodes, press the 
  182. \i Unprotect
  183. \i0  button.  Pressing 
  184. \i Protect
  185. \i0  again cleans the slate of recorded nodes.\
  186. When touched nodes are being displayed, some new types of nodes are listed.  Nodes marked with a '+' were allocated since the 
  187. \i Protect
  188. \i0  button was pressed.  Nodes marked with a '-' were allocated and freed since the 
  189. \i Protect
  190. \i0  button was pressed.\
  191. WindowTemplate
  192. iiii***@s@
  193. Panel
  194.     HelpPanel
  195. ScrollingText
  196. File's Owner
  197. IBOutletConnector
  198. IBConnector
  199. window
  200.