Debugging Memory Problems with MemoryScape : Chapter 2 Memory Tasks : Task 16: Painting Memory

Task 16: Painting Memory
Your program may be using memory either before it is initialized or after it is deallocated. MemoryScape can help you identify these kinds of problems by initializing allocated or deallocated memory to a bit pattern. This is called painting. If you can recognize this bit pattern, you’ll be taking a large step toward identifying the problem.
Before reading this task, you should be familiar with the following information:
Chapter 1, “Locating Memory Problems”
Contains an overview of memory concepts and MemoryScape.
Task 1: “Getting Started”
Tells you how to start MemoryScape. It also contains an overview of the kinds of information you can­ obtain.
Task 3: “­Setting MemoryScape Options”
Describes configuring MemoryScape so that it performs the activities you want it to perform.
Task 4: “Controlling Program Execution”
Shows how to start and stop program execution.
Tell MemoryScape to paint memory by selecting the Memory Debugging Options screen. (This is described in Task 3: “­Setting MemoryScape Options”.) Next, select Extreme. If you need to tune how MemoryScape paints memory, select Advanced Options. Here is the portion of the options screen for setting painting options:
 
The following list describes some of the ways in which you use ­painting:
*
If you paint memory and your application displays this memory, you will have proof that you are using uninitialized or deallocated ­memory.
*
Painting memory provides consistency for uninitialized memory in that you should not experience situations where the program works for some users and doesn’t for others.
*
Painting memory will change your program’s behavior if it is not using memory correctly. This may aid in identifying the problem. In addition, it may correct the problem so that the program doesn’t appear to fail.
*
Some painting patterns can force an error such as a crash to occur. (Crashes during debugging sessions are “good.” They allow you to identify where problems are occurring.)
*
After painting memory, your program can look for the pattern in order to check if something was not initialized.

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