Debugging Dynamic Memory Usage Errors Using NonStop Native Inspect White Paper

NOTE: The “<system/unknown>” function displayed indicates memory allocated from an unknown
function (function with no name) or system routine.
Leak Profiling
The leak profile feature in Native Inspect conservatively identifies the blocks of memory that are
leaked in an application, and displays the stack trace that shows when the block was allocated.
All the leaks detected by Native Inspect are definite physical leaks.
Native Inspect uses a garbage collection algorithm to identify the blocks that are leaked. It identifies
the root-set of memory that indicate possible pointers to the heap. The initial root-set includes the
shared library data, the program stack, the registers. The initial root-set includes all data except
the heap blocks.
The debugger considers suitably aligned words in the root-set as possible pointers to the heap.
The debugger performs a reachability analysis based on the root-set, and determines the memory
blocks that are reachable through possible pointers from the root-set. The heap blocks that are not
reachable through possible pointers from the root-set are reported as leaks.
Native Inspect is conservative in detecting the memory leaks. The memory leaks can be masked if
a datum in the root-set inadvertently holds a possible pointer to a heap block. An example of
“inadvertently would be where a pointer value is held in a floating point variable instead of one
that is declared pointer to.
Table 3 Commands for Leak Profiling
DescriptionCommand
Controls Native Inspect memory leak checking.set heap-check leaks <on/off>
Displays a leak report. It also lists information such as the
leaks, size of blocks, and number of instances.
info leaks
Writes the complete leak report output to the specified file.
If a filename is given, the output produced in the file is a
info leaks <filename>
detailed output. Meaning the trace of each leak is also
provided.
Displays detailed information on the specified leak
including the allocation call stack.
info leak <leaknumber>
Specifies the minimum leak size for stack trace collection.
The debugger continues to report leaks that are smaller
set heap-check min-leak-size <num>
than <num> bytes, but it does not provide the stack trace
for the same. By default, num is set to 0. This command
also enables you to reduce performance degradation. See
“Settings to Manage Performance Degradation.
To view the leak profile, complete the following steps:
1. Run the debugger and load the program by entering the following command:
> rund <executable>/debug, lib $system.sys00.zrtcdll/ <arguments>
2. Enable leak checking by entering the following command:
(eInspect 0,105): set heap-check leaks on
Memory-Debugging Features of Native Inspect 11