Debugging Dynamic Memory Usage Errors Using HP WDB (5900-1474; WDB 6.2; January 2011)
The typical causes for logical leaks are listed below:
◦ Leaks caused by premature allocation of memory
The application allocates the memory much ahead of the actual use of the
allocated memory.
◦ Leaks caused by delayed de-allocation
The application delays the freeing the allocated block beyond the actual use of
the allocated memory.
◦ Leaks caused by failure to utilize allocated memory
The application allocates memory, but fails to use the allocated memory.
NOTE: WDB supports the debugging of physical memory leaks only. It does not
detect logical memory leaks.
Access Errors
Memory access errors can occur under the following conditions:
• When reading uninitialized local, or heap data
• When reading or writing to nonexistent, unallocated, or unmapped memory
• When a stray pointer overflows the bounds of a heap block, or tries to access a
heap block that is already freed to cause buffer overruns and under-runs
• When reading or writing to memory locations that are already freed in the program
NOTE: WDB provides minimal support for debugging some of the memory access
errors. The scrambling feature and detection for out-of-bounds writes are supported by
WDB.
Using WDB to Debug Memory Problems
WDB supports the memory-debugging of applications involving dynamic allocations and
de-allocations of virtual memory blocks, or during the calls to libc string routines like
strcpy(), and memcpy(). It debugs memory-related problems at the time of allocation
or de-allocation of memory blocks. It supports the detection of outstanding memory-related
problems at specific user-defined probe-points (breakpoints) during the use of the memory
blocks. Memory-related problems that appear after the specified probe points are not
detected. It does not support the debugging of access errors that are caused when reading
from or writing to unallocated, uninitialized, or de-allocated memory.
WDB does not support the memory-debugging of the stack, static memory, and register
memory.
10