Dangling Pointer Problems
 
Fixing dangling pointer problems is usually more difficult than fixing other memory problems. First of all, you become aware of them only when you realize that the information your program is manipulating isn’t what it is supposed to be. Further, these problems can be intermittent, occurring only when your program’s heap manager reuses a memory block. For example, if nothing else is running on your computer, your program may never reuse the block. If there are a large number of jobs running, it could reuse a deallocated block quickly.
After you identify that you have a dangling pointer problem, you have two problems to solve. The first is to determine where your program freed the memory block. The second is to determine where it should free this memory.
When memory debugging is enabled, TotalView identifies dangling pointers in the Local Variable view and the Data View. You can also tag specific memory blocks so you are notified when memory is allocated or freed. See Memory Block Notification.
Memory debugging options that can help identify dangling pointers include:
*Painting memory, in whichTotalView writes a bit pattern into allocated and deallocated memory blocks. See Option: Painting Memory.
*Hoarding, in which TotalView holds onto a memory block when the heap manager receives a request to free it. See Option: Hoarding Memory Blocks.
This is most often used to get beyond the location where a problem occurs. By allowing the program to continue executing with correct data, you sometimes have a better chance to find the problem. For example, if you also paint the block, it becomes easy to tell what the problem is. If your program then crashes, you will immediately know where the problem is.)
*Watchpoints, in which TotalView stops execution when a new value is written into a memory block. If TotalView is painting deallocated blocks, you immediately know where your program freed the block. See Watchpoints.
*Block tagging, in which TotalView stops execution when your program deallocates or reallocates memory. See Memory Block Notification.