Please enable JavaScript to view this site.

Memory Validator Help

Navigation: Examples

Finding uninitialised memory

Scroll Prev Top Next More

 

Detecting uninitialised memory

 

The example program is run once and we use the Memory and Analysis view to observe and investigate any uninitialised memory.

 

mvMemVal

 

menu Settings menu instructionStep Edit Settings... instructionStep Data Collection instructionStep Collect page instructionStep check Uninitialised Data instructionStep enables the use of Uninitialized Data hooks

 

launch nativeExample.exe instructionStep wait until attaching is complete

 

 

nativeExample1  

 

menu Memory Errors menu instructionStep Uninitialized Data instructionStep Objects on Heap instructionStep Allocates and frees an object with uninitialized data members

 

menu File menu instructionStep Exit

 

 

mvMemVal

 

wait for data transfer to complete

 

Memory tab instructionStep Refresh instructionStep shows the usual leaks and also uninitialised data use in the colour defined.

 

example-uninitialised-memory

 

expand the most recent uninitialised item instructionStep expand the OnUninitialiseddataObjectsonheap entry on the callstack instructionStep shows the source for the allocation

 

The information shows that in the allocation of a TestClass object, the data member data2 was not initialised:

 

example-uninitialised-memory-expanded1

 

noteThe callstack may not always be present for all uninitialized data.

 

The display should show another uninitialised data item earlier in the event history.

 

This doesn't show a full callstack or data member names, but does show the size, address and relative offsets of the uninitialised data  

 

example-uninitialised-memory-expanded2

 

No callstack? Which object?

 

If your program has uninitialised data but the callstack isn't available:

 

Make a note of the object address - for example in our first example above 0x02171458
 

Analysis tab instructionStep Memory... instructionStep shows the Find Memory in Analysis dialog

 

Disable All instructionStep enable Find objects in address range instructionStep enter address range (e.g. 0x02171458 to 0x02171458) instructionStep Find... instructionStep shows matching objects

 

You can also set the range to search for object containing that address or the allocation address plus the offset size.

 

 example-uninitialised-memory-find

 

The results of the search (if any) are highlighted on the display, showing a TestClass object of size 8 bytes at that address:

 

example-uninitialised-memory-find-results1

 

select the later of the two results instructionStepright_mouse_buttonRelations instructionStep Relations to 'this' instructionStep Allocator of this instructionStep shows the allocation event for this object in the Relations pane

 

Expanding these traces shows the callstacks for the deallocation and the allocation of the object that has the uninitialized data.

 

 example-uninitialised-memory-find-results2