Debugging Memory Problems with MemoryScape : Chapter 1 Locating Memory Problems : Batch Scripting and Using the CLI : dheap : Deallocation Notification: dheap –tag_alloc

Deallocation Notification: dheap –tag_alloc
You can tell MemoryScape to tag information within MemoryScape’s tables and to notify you when your program either frees a block or passes it to realloc() by using the following two commands:
*
dheap –tag_alloc –notify_dealloc
*
dheap –tag_alloc –notify_realloc
Tagging is done within MemoryScape’s agent. It tells MemoryScape to watch those memory blocks. Arguments to these commands tell MemoryScape which blocks to tag. If you do not type address arguments, TotalView notifies you when your program frees or reallocates an allocated block. The following example shows how to tag a block and how to see that a block is tagged:
d1.<> dheap -tag_alloc -notify_dealloc 0x8049a48
process 1 (19387): 1 record(s) update
d1.<> dheap -info
process 1 (19387):
0x8049a48 -- 0x8049b48 0x100 [ 256]
flags: 0x2 (notify_dealloc)
0x8049b50 -- 0x8049d50 0x200 [ 512]
flags: 0x0 (none)
0x8049d58 -- 0x804a058 0x300 [ 768]
flags: 0x0 (none)
Using the –notify_dealloc subcommand tells MemoryScape to let you know when a memory block is freed or when realloc() is called with its length set to zero. If you want notification when other values are passed to the realloc() function, use the –notify_realloc subcommand.
After execution stops, here is what the CLI displays when you type another dheap –info command:
d1.<> dheap -info
process 1 (19387):
0x8049a48 -- 0x8049b48 0x100 [ 256]
flags: 0x3 (notify_dealloc, op_in_progress)
0x8049b50 -- 0x8049d50 0x200 [ 512]
flags: 0x0 (none)
0x8049d58 -- 0x804a058 0x300 [ 768]

Rogue Wave Software, Inc.
Voice: (303) 473-9118
rwonlinedocs@roguewave.com