Debugging Dynamic Memory Usage Errors Using HP WDB
LD_PRELOAD=/opt/langtools/lib/pa20_64/librtc.sl <executable> <arguments>
2. Identify the required process (using the ps command) and attach the debugger to the process
as follows.
gdb -leaks <executable-name> <process-id>
3. Insert breakpoints at suitable probe-points. When the breakpoints trigger, use the info
heap and info leaks commands to display the heap and leak profile.
Summary of Memory Debugging Commands
Most of the commands available in the interactive and the attach modes are also available in the
batch mode. Table 15 “Commonly Used Commands for Memory Debugging”lists the commands
that are available in the batch mode and the equivalent commands in the interactive mode. It
also lists the commands that are not supported in the batch mode.
Table 15 Commonly Used Commands for Memory Debugging
Batch ModeInteractive Mode/Attach ModeDescription
set heap-check <on/off>set heap-check <on/off>
Enables heap profiling
set heap-check leaks <on/off>set heap-check leaks
<on/off>
Enables you to detect leaks.
set heap-check free <on/off>set heap-check free <on/off>
Enables you to detect double-frees
and frees with improper arguments
set heap-check scramble
<on/off>
set heap-check scramble
<on/off>
Enables you to scramble blocks.
set heap-check bounds
<on/off>
set heap-check bounds
<on/off>
Enables you to check for
out-of-bounds corruption when the
block is freed.
set heap-check string
<on/off>
set heap-check string
<on/off>
Enables validation of calls to
strcpy(), strncpy(), memcpy(),
memccpy(),memset(), memmove(),
bzero(), and, bcopy()
set heap-check frame-count
<num>
set heap-check frame-count
<num>
Enables you to set the number of
frames to be printed for leak and heap
profiles.
set heap-check min-heap-size
<num>
set heap-check min-heap-size
<num>
Enables you to set the minimum
block size to report in heap profiles.
set heap-check min-leak-size
<num>
set heap-check min-leak-size
<num>
Enables you to set the minimum
block size to use for leak detection.
Not supported in Batch Mode
set heap-check watch address
Stops program execution when the
block at the given address is allocated
or de-allocated
Not supported in Batch Mode
info corruption
Checks for corruption in the currently
allocated heap blocks
Not supported in Batch Mode
set heap-check null-check
<num>
Forces malloc() to return NULL
after <N> invocations of malloc()
Not supported in Batch Mode
set heap-check
null-check-size <size>
Forces malloc() to return NULL
after <N> bytes are allocated by the
program
64