Debugging Memory Problems with MemoryScape™ : Chapter 2 Memory Tasks : Task 3: ­Setting MemoryScape Options : Advanced Options : Halt execution on memory event or error
Halt execution on memory event or error
When selected, MemoryScape halts your program’s execution just before it detects that a problem will occur when your program calls a function in the malloc library. We recommend that you leave this set
 
Figure 42: Halt execution on memory event or error
When your program allocates memory, MemoryScape records this and other information in an internal table. Every time your program deallocates or reallocates memory, it checks what is about to be done against this information. If it detects that a problem will occur, it stops execution and displays an event indicator, shown in Figure 43.
Figure 43: Event Indicators
MemoryScape can watch for a number of events. Its default is to watch for all, but you can specify specific events using the Advanced button which launches the Memory Event Actions Dialog Box, Figure 44.
 
Figure 44: Memory Event Actions Dialog Box
 
NOTE >> This snapshot was created using TotalView Debugger Team and Team Plus. If you are not licensed for these products, then the two options Generate a core file and abort the program and Generate a lightweight memory data file are unavailable.
1. Select events to trigger: Select or unselect events. In most cases, you should unselect events coming from a library or system you can’t control.
2. When the above events trigger: Select the action to perform, as follows:
Stop the process and show the event details: When selected, additional options are available to generate a core file or lightweight memory file.
Generating a core file: MemoryScape writes the file to disk and aborts execution. (The operating system routines that generate a core file cause the program to be aborted.) As you are still within MemoryScape, you can restart your program.
G enerate a lightweight memory file: MemoryScape creates a file similar to that written when you use the File > Export command. This files can then be read back into MemoryScape in the same way as exported .dbg files. In contrast to a core file, your program continues to execute after MemoryScape writes the file.
You can name the directory into which the MemoryScape writes the file by identifying the location in the Directory field or use the Browse button to navigate to a directory.
You can control this file’s name using the Naming Options button which launches the Memory Data File Options dialog, Figure 45.
 
Figure 45: Memory Data File Options
If you change the prefix or file extension, the change is reflected in the Preview area.