Debugging Dynamic Memory Usage Errors Using HP WDB
Monitoring Changes in Data Segment Space Allocation (High Water Mark Feature)
The high water mark feature records the number of times the break value changes which is the
number of times the heap grows.
The high water mark feature monitors changes in the program break value. This value points to
the end of the heap (which is also the end of the data segment). When memory is allocated using
malloc() in excess of the available heap memory, the brk() call extends the heap. This changes
the break value. Most implementations of malloc() do not decrease the heap size when the
memory is freed. The break value is indicative of the memory consumption by the program.
Table 10 lists the commands that support the high water mark feature.
Table 10 Commands Supporting High Water-Mark Feature
DescriptionCommand
Displays the number of times that the break value has
been changed for the current run at the instant, the
command is issued
info heap high-mem
Stops when break value has moved the specified number,
<X_number>, of times
set heap-check high-mem-count <X_number>
NOTE: This feature assumes that an application has a deterministic memory allocation pattern
from one run to another.
The info heap high-mem command displays the maximum number of times the break value
changes for a given run. The set heap-check high-mem-count <X_number> stops program
execution when the break value moves a specified number <X_number> of times, and transfers
execution control to the user. Both these commands display the size and call site of the last
memory allocation that extended the high water mark.
This feature also enables you to analyze the memory-usage in an application and check if the
memory-usage is critical or close to triggering an out-of-memory error.Example 10 (page 44)
illustrates the high water mark feature.
Memory-Debugging Features of WDB 43