Debugging Dynamic Memory Usage Errors Using HP WDB (5900-1474; WDB 6.2; January 2011)
WDB supports the following heap-analysis profiles:
• Snapshot Profile
• Incremental Heap Profile
• Arena Profile
NOTE: Heap profiling must be enabled to view heap reports. The set heap-check
on command enables heap profiling also.
Snapshot Profile
The snapshot 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.
Table 4 lists the basic commands used for heap profiling.
Table 4 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 complete report output containing the
heap summary as well as the details 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 of bytes that are allocated at each call-site
inclusive of multiple calls to malloc() at a particular
call site. See Example 1 (page 16) for more
information.
set heap-check min-heap-size <num>
To obtain a snapshot heap profile, complete the following steps:
1. Run the debugger and load the program by entering the following command at
command prompt:
$ gdb <executable> <arguments>
(gdb) set heap-check on
NOTE: The set heap-check on command enables the memory-debugging
feature in WDB. This enables the detection of leaks, heap profiles, bounds checking,
checking for double free
2. Set a breakpoint by entering the following command:
Memory-Debugging Features of WDB 13