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.
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.”