The example program is run once and we use the Memory and Analysis view to observe and investigate any uninitialised memory.
Settings menu Edit Settings... Data Collection Collect page check Uninitialised Data enables the use of Uninitialized Data hooks
launch nativeExample.exe wait until attaching is complete
Memory Errors menu Uninitialized Data Objects on Heap Allocates and frees an object with uninitialized data members
File menu Exit
wait for data transfer to complete
•Memory tab Refresh shows the usual leaks and also uninitialised data use in the colour defined.
•expand the most recent uninitialised item expand the OnUninitialiseddataObjectsonheap entry on the callstack shows the source for the allocation
The information shows that in the allocation of a TestClass object, the data member data2 was not initialised:
The 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
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 Memory... shows the Find Memory in Analysis dialog
•Disable All enable Find objects in address range enter address range (e.g. 0x02171458 to 0x02171458) Find... shows matching objects
You can also set the range to search for object containing that address or the allocation address plus the offset size.
The results of the search (if any) are highlighted on the display, showing a TestClass object of size 8 bytes at that address:
•select the later of the two results Relations Relations to 'this' Allocator of this 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.