Debugging Dynamic Memory Usage Errors Using HP WDB (5900-1474; WDB 6.2; January 2011)
Example 10 High Water-Mark Feature
Sample Program
$cat high.c
1 #include <stdio.h>
2 #include <malloc.h>
3
4 char * func1()
5 {
6 char *ptr;
7 ptr = malloc(1000);
8 return ptr;
9
10 }
11
12 char * func2()
13 {
14 char *ptr;
15 ptr = malloc (100);
16 return ptr;
17
18 }
19
20 void func4()
21 {
22 char *ptr;
23 ptr = malloc (9000);
24 free (ptr);
25
26 }
27
28 void main()
29 {
30 char* ptr;
31 int i;
32
33 for (i=0; i<100; i++)
34 {
35 ptr = func1();
36 free(ptr);
37 }
38 ptr = func2();
39 func4();
40 }
Sample Debugging Session
Case 1: The info heap high-mem command displays the number of times that the
break value changes for a given run and to display the highest break value in the current
run.
Memory-Debugging Features of WDB 43