In large programs, it is nearly impossible to determine if your program is accessing memory that has been allocated and initialized or if it is erroneously accessing memory that was deallocated.

The Memory Debugger can help you identify these kind of problems by writing a value into memory locations that your program allocates or deallocates. Writing this pattern is called block painting.[/url]

To enable painting:
  1. [/url]Select the Tools > Memory command.
  2. [/url]Check the Enable memory debugging option.
  3. [/url]Open the Block Painting area by clicking on the + symbol.
  4. [/url]Change the pulldowns for Paint allocations and Paint deallocations from Pending to On. (Pending means that the Memory Debugger will use default values and doesn't yet know what these values are.)[br]

[/url]After your program begins executing, you can open a Variable Window that contains a variable residing in allocated memory. You'll now be able to tell what was initialized.

[/url]These snapshots were taken just after the program allocated memory for the red_balls variable and before it sets values to structure members. The upper-left snapshot shows the memory's allocation/deallocation status. The middle window shows the structure's elements. The memory debugger set the values for the value, spare and colour members to 0xa110ca7f. Because colour points to memory that hasn't yet been allocated, TotalView also displays a bad address message.
[/url]The values for x and y show the double precision equivalent to 0xa110ca7f pattern. This is shown in the bottom-right window, where the Type for variable x was changed to int[2].