Debugging Memory Problems with MemoryScape : Chapter 2 Memory Tasks : Task 3: ­Setting MemoryScape Options : Advanced Options : Guard allocated memory

Guard allocated memory
When your program allocates a memory block, MemoryScape can write additional memory segments both before and after the block. These segments are called guards. Immediately after creating the guards, MemoryScape also initializes them to a bit pattern.
These guards can help you identify corrupted memory in two ways:
*
When your program deallocates a memory block, MemoryScape checks to determine if the pattern differs from what it was when it first wrote the block. If it is, your program will have overwritten memory that it shouldn’t have used. This indicates that memory was corrupted. (MemoryScape writes one pattern into the guard preceding a block and another into the one after it.)
*
Whenever you halt execution, you can ask MemoryScape to check for corrupted guard blocks. The checking looks at all guard blocks surrounding your allocations.
For information on using guard blocks, see Task 11: “Viewing Corrupted Memory”.
Enable guard blocks either by selecting a level of Medium or selecting the check box in the Advanced screen. Figure 46 shows the portion of that screen that controls guard blocks.
 
The controls in this area let you change the size of guard blocks and their pattern.
You can also set a maximum size for the guard blocks that surround a memory allocation. The need for this control is not self-evident until you understand that the size actually used for a guard block can be greater than the pre-guard and post-guard sizes due to the way an operating system aligns information. If memory is tight, setting a value here ensures that blocks do not use an excessive amount of memory.
If the value is set to zero (0), which is the default, MemoryScape doesn’t set a maximum size.

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