Debugging Dynamic Memory Usage Errors Using HP WDB (5900-1474; WDB 6.2; January 2011)
Example 1 Filtered Heap Reporting for Allocations Exceeding <num> at a Particular
Call-Site
Sample Program
1 #include <stdio.h>
2 #include <stdlib.h>
3 main()
4 {
5 int i, *arr[1000];
6 for (i=0; i < 1000; i++)
7 arr[i] = malloc (49);
8 malloc (30);
9 set_brkpt_here(0)
10 exit(0);
11
12 }
Sample Debugging Session
$ gdb minheap
(gdb) b set_brkpt_here
(gdb) set heap-check min-heap-size 31
(gdb) run
(gdb) info heap
Analyzing heap ...
49000 bytes allocated in 1000 blocks
No. Total bytes Blocks Address Function
0 49000 1000 0x4044eff0 main()
Incremental Heap Profile
The incremental profile displays the outstanding allocations at multiple probe points in
an application at runtime. This profile is analogous to processing multiple snapshot
profiles. Example 2 (page 18) illustrates this feature.
Table 5 lists the commands for incremental heap-profiling.
16