Поделиться через


CMemoryState::DumpStatistics

Prints a concise memory statistics report from a CMemoryState object that is filled by the Difference member function.

void DumpStatistics( ) const;

Remarks

The report, which is printed on the afxDump device, shows the following:

A sample report gives information on the number (or amount) of:

  • free blocks

  • normal blocks

  • CRT blocks

  • ignore blocks

  • client blocks

  • maximum memory used by the program at any one time (in bytes)

  • total memory currently used by the program (in bytes)

Free blocks are the number of blocks whose deallocation was delayed if afxMemDF was set to delayFreeMemDF. For more information, see afxMemDF, in the "MFC Macros and Globals" section. See Types of Blocks on the Debug Heap for more information on these block types.

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(_T("Memory leaked\n"));
   diffstate.DumpStatistics();
}

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

Requirements

Header: afx.h

See Also

Reference

CMemoryState Structure

Hierarchy Chart

Other Resources

CMemoryState Members