\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.
\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.\
\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
\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
\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 (
\b malloc
\b0 ,
\b realloc
\b0 ,
\b calloc
\b0 , or
\b valloc
\b0 ) or one of NeXT's zone allocation functions (
\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.\
\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,
\pard\tx1040\tx2100\tx3160\tx4220\tx5280\tx6320\tx7380\tx8440\tx9500\tx10560\fc0\cf0 a right arrow (`>')
\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
\b strlen(s)
\b0 as the argument to
\b malloc
\b0 for a string instead of
\b strlen (s) + 1
\b0 . Damaged nodes are listed first in all sorting modes.\
\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
\i conservative
\i0 . In practice, this problem is very rare.\
The second caveat is that the garbage detector only searches for references to the
\i beginning
\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.\
\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
\i Mark
\i0 button. After exercising a portion of your program, press the
\i New
\i0 button to see the nodes allocated since the mark. Note that
\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.\
To record which nodes are touched,
\b MallocDebug
\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
\b libMallocDebug.a
\b0 (see above), you must run the
\b mdbsetup
\b0 program on your application to enable per-node monitoring for various zones. The command\
\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.\
\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.\
After applying
\b mdbsetup
\b0 to your application, run the application and select it in
\b MallocDebug
\b0 as described above. To learn what nodes are touched for a given operation of your application, first press the
\i Protect
\i0 button. Then perform the operation in your application. While you are using the application,
\b MallocDebug
\b0 records which nodes are touched. To see this list, press the
\i Touched
\i0 button. To see what nodes have not been touched, press the
\i Untouched
\i0 button. To stop the recording of touched nodes, press the
\i Unprotect
\i0 button. Pressing
\i Protect
\i0 again cleans the slate of recorded nodes.\
When touched nodes are being displayed, some new types of nodes are listed. Nodes marked with a '+' were allocated since the
\i Protect
\i0 button was pressed. Nodes marked with a '-' were allocated and freed since the