Debugging Memory Problems with MemoryScape : Chapter 2 Memory Tasks : Task 3: ­Setting MemoryScape Options : Advanced Options : Use Red Zones to find memory access violations

Use Red Zones to find memory access violations
When your program allocates a memory block, MemoryScape can write an additional memory buffer either before or after the block. These buffers are called Red Zones. MemoryScape watches the Red Zone for illegal read or write access.
Red Zone controls appear on the toolbar only on platforms that support Red Zone capabilities. See the Platform Guide for specific platform support.
Red Zones can help you identify where an illegal access occurs in three cases:
*
*
Underruns: reads or writes before the bounds of the allocated block, detected by placing a Red Zone before the block.
*
Enable Red Zones by setting the debugging level to High, or by selecting the option “Use Red Zones to find memory access violations” on the Advanced Options screen, as shown in Figure 47
 
The controls on this screen let you select the type of error to detect, and define ranges and values for some of the detection types. In addition to detecting overruns and underruns, discussed above, you can customize Red Zone definitions, discussed in “Customizing Red Zones”.
If you select “Detect memory access after it has been freed” you will be notified when this occurs. MemoryScape will retain the deallocated blocks to monitor them for both read and write access. This option will increase memory consumption in your program.
One way to limit the overhead incurred in using Red Zones is to restrict their use to blocks of specified sizes. (See “Restricting Red Zones” for details on using the option “Restrict Red Zones to allocations within size ranges.”) Another way is to turn Red Zones on and off during program execution using the Red Zones button ,on the tool bar. Because of the increased memory consumption associated with Red Zones, use them with caution.
If you would like to know when your program exits due to an access violation, use the last option, “Set the exit value for an access violation.

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