Debugging with GDB Manual (5900-1473; WDB 6.2; January 2011)

Table Of Contents
14.10.4 Debugging Memory in Interactive Mode
This section describes the various commands which help in debugging memory problems
when the debugger is used in the interactive mode.
14.10.4.1 Commands for interactive memory debugging
To debug memory problems, use these commands:
set heap-check [on|off] This toggles the capability for detection of leaks,
heap profiles, bounds checking, and checking for
double free.
info heap Displays a heap report, listing information such
as the start of heap, end of heap, heap size, heap
allocations, size of blocks, and number of
instances. The report shows heap usage at the
point you use the info heap command. The
report does not show allocations that have already
been freed. For example, if you make several
allocations, free them all, and then you use info
heap, the result does not show any allocations.
info heap filename Writes the complete report output containing the
heap summary as well as the details to the
specified file.
info heap idnumber Produces detailed information on the specified
heap allocation including the allocation call stack.
show heap-check Displays all current settings for memory checking.
set heap-check interval <
nn >
This command starts incremental heap growth
profile. All allocations prior to the execution of
this command are ignored from report. If
incremental heap growth profile is already on,
executing this command will reset the counters
and start a fresh collection. Interval is specified in
seconds.
set heap-check repeat < nn
>
This allows user to specify the number of intervals
GDB should collect the incremental heap growth.
The default value is 100. Every repeat of the
interval tracks heap allocation during that interval.
Example:
< gdb > set heap-check interval 10
< gdb > set heap-check repeat 100
Here HP WDB will create 100 incremental apart
heap profiles which are 10 seconds apart.
14.10 Debugging Memory Problems 153