The following code should be placed in projnameApp.cpp. Define the following global variables:
static CMemoryState oldstate, newstate, diffstate;
In the InitInstance function, add the line:
Add a handler for the ExitInstance function and use the following code:
newstate.Checkpoint();
if (diffstate.Difference(oldstate, newstate))
{
TRACE(_T("Memory leaked\n"));
diffstate.DumpStatistics();
}
You can now run the program in Debug mode to see the output of the DumpStatistics function.