CMemoryState::DumpStatistics

void DumpStatistics( ) const;

Remarks

Prints a concise memory statistics report from a CMemoryState object that is filled by the Difference member function. The report, which is printed on the afxDump device, shows the following:

A sample report looks like this:

0 bytes in 0 Free Blocks
8 bytes in 2 Object Blocks
0 bytes in 0 Non-Object Blocks
Largest number used: 8 bytes
Total allocations: 8 bytes

Example

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:

oldstate.Checkpoint();

Add a handler for the ExitInstance function and use the following code:

   newstate.Checkpoint();
   if (diffstate.Difference(oldstate, newstate))
      {
      TRACE("Memory leaked\n");
      diffstate.DumpStatistics();
      }
   return 0;

You can now run the program in Debug mode to see the output of the DumpStatistics function.

Output

Memory leaked
0 bytes in 0 Free Blocks.
-626 bytes in -13 Normal Blocks.
0 bytes in 0 CRT Blocks.
0 bytes in 0 Ignore Blocks.
-1212 bytes in -6 Client Blocks.
Largest number used: 178 bytes.
Total allocations: 988 bytes.

CMemoryState OverviewClass MembersHierarchy Chart