| for the footer is 16 bytes if this option is not used. |
| If the user specifies a value less than 16 for the |
| number of bytes, the debugger ignores it and |
| takes the default of 16 bytes. If the user specifies |
| more than 16 bytes, then the debugger considers |
| the largest and closest 16 byte integral from the |
| |
| Example: |
| If the user specifies 60 bytes, the debugger takes |
| it as 48 bytes. If the user specifies 65, the |
| debugger considers 64 bytes. |
set | Sets the Footer guard for each block of the |
num of bytes | allocated memory. The default number of bytes |
| for the footer is one byte if this option is not used. |
14.10.4.2 Example for interactive debugging session
This example describes checking a program running on
1.Link the program with /usr/lib/libc.sl instead of libc.a.
2.Run the debugger and load the program:
> gdb a.out
3.Turn on leak checking:
(gdb) set
4.Set one or more breakpoints in the code where you want to examine cumulative leaks:
(gdb) b myfunction
5.Run the program in the debugger:
(gdb) run
6.Use the info command to show list of memory leaks:
(gdb) info leaks
Scanning for memory leaks...done 2439 bytes leaked in 25 blocks
No. Total bytes Blocks Address Function 0 1234 1 0x40419710 foo()
1 333 1 0x40410bf8 main()
2 245 8 0x40410838 strdup() [...]
14.10 Debugging Memory Problems 163