Using MemoryScape Options
Before your program begins execution, you can set other options by selecting controls in the Memory Debugging Options screen show in Figure 15. (Some of these options can be set at other times.) Here’s a summary of these options:
*Halt execution at process exit—Stops execution before your program exits. This lets you analyze the memory information that MemoryScape has collected. If the program does finish executing, MemoryScape discards this memory information, and you can no longer view its reports.
*Halt execution on memory event or error— Stops execution and notifies you if a heap event such as a deallocation or a problem occurs. This is called event notification. (See Event and Error Notification” for more information.) By default, this is set to On.
*Guard allocated memory—Surrounds allocations with a small amount of additional memory. By default, it uses 8 bytes of memory. It also writes a pattern into this memory. These additional memory blocks are called guard blocks. If your program overwrites these blocks, you can tell that a problem occurred either by asking for a report or by an event notification when your program deallocates a guarded block.
*Use Red Zones to find memory access violations—Adds a Red Zone to your allocated blocks. The Red Zone is an additional page of memory located either before or after your block. If MemoryScape detects access in the Red Zone that is outside the bounds of your allocated block, it halts execution of your program and notifies you of the underrun or overrun. For more information see Using Red Zones”.
*Paint memory—Paints allocated and deallocated memory and the pattern that MemoryScape uses when it paints this memory. For more information, see Finding free() and ­realloc() Problems” and Task 3: “­Setting MemoryScape Options”.
*Hoard deallocated memory—Retains deallocated memory blocks, how much memory to use for these blocks, and the number of blocks to retain. For more information, see Task 3: “­Setting MemoryScape Options”.