Debugging Memory Problems with MemoryScape : Chapter 1 Locating Memory Problems : Batch Scripting and Using the CLI : Using the -dheap Command : Notification When free Problems Occur
Notification When free Problems Occur
If you type dheap -enable -notify and then run your program, MemoryScape notifies you if a problem occurs when your program tries to free memory.
When execution stops, you can type dheap (with no arguments), to display information about what happened. You can also use the dheap -info and dheap -info -backtrace commands to display additional information. The information displayed by these commands lets you locate the statement in your program that caused the problem. For example:
d1.<> dheap
process: Enable Notify Available
1 (18993): yes yes yes
1.1 realloc: Address does not match any allocated block.:
0xbfffd87c
For each allocated region, the CLI displays the start and end address, and the length of the region in decimal and hexadecimal formats. For example:
d1.<> dheap
process: Enable Notify Available
1 (30420): yes yes yes
1.1 free: Address is not the start of any allocated block.:
free: existing allocated block:
free: start=0x08049b00 length=(17 [0x11])
free: flags: 0x0 (none)
free: malloc PC=0x40021739 [/.../malloc_wrappers_dlopen.c]
free: main PC=0x0804871b [../free_prob.c]
free: __libc_start_main PC=0x40140647 [/lib/i686/libc.so.6]
free: _start PC=0x080485e1 [/.../free_prob]
free: address passed to heap manager: 0x08049b08
MemoryScape can also tell you when your program deallocates or reallocates tagged blocks. For more information, see Deallocation Notification: dheap -tag_alloc”.