Debugging Dynamic Memory Usage Errors Using NonStop Native Inspect White Paper

Heap Profiling
You can profile the heap usage in an application by using Native Inspect. The heap-profiling
feature enables you to analyze the influence of algorithms and data structures on heap usage and
tune the memory requirements of an application.
The point-in-time (meaning the application is suspended at some point in execution) profile displays
the outstanding heap allocations at a specific instant (probe point) at runtime. It does not display
the blocks that are already freed before the probe point. Native Inspect supports this point-in time
heap-analysis type profile of memory use.
NOTE: Heap profiling must be enabled to view heap reports. The set heap-check on
command enables heap profiling.
Table 2 Commands for Heap Profiling
DescriptionCommand
Displays the heap report that includes the current heap
allocations, the sizes of the blocks allocated, and number
of allocation instances.
info heap
Writes the heap report output to the specified file.info heap <filename>
Displays detailed information about the specified heap
allocation including the allocation call stack.
info heap <idnumber>
Reports the heap allocations that exceed the specified
number,<num> , of bytes based on the cumulative number
set heap-check min-heap-size <num>
of bytes that are allocated at each call-site inclusive of
multiple calls to malloc()at a particular call site. See
“Example 1” (page 10) for more information.
To obtain a point-in-time heap profile, complete the following steps:
1. Run the debugger and load the program by entering the following command at command
prompt:
> rund <executable> /lib $system.sys00.zrtcdll/ <arguments>
(eInspect 0,105): set heap-check on
And for OSS:
: run debug lib /G/system/sys00/zrtcdll <arguments>
(eInspect 0,105): set heap-check on
NOTE: The set heap-check on command enables the memory-debugging feature in
Native Inspect. This enables the detection of leaks, heap profiles, bounds checking, checking
for double free.
2. Set a breakpoint by entering the following command:
(eInspect 0,105): b <probepoint>
3. Run the program by entering the following command:
(eInspect 0,105):continue
4. When the program is stopped at a breakpoint, enter the following info heap command:
(eInspect 0,105): info heap
The following output is displayed:
Analyzing heap ...
Actual Heap Usage:
Heap Start = 0x08001000
Heap End = 0x0843d000
Heap Size = 4440064 bytes
Outstanding Allocations:
Memory-Debugging Features of Native Inspect 9