Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual C++
MFC
MFC Classes
 CMemoryState::DumpStatistics

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
MFC Library Reference
CMemoryState::DumpStatistics

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

void DumpStatistics( ) const;

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.

The following code should be placed in projnameApp.cpp. Define the following global variables:

Visual C++
static CMemoryState oldstate, newstate, diffstate;

In the InitInstance function, add the line:

Visual C++
oldstate.Checkpoint();

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

Visual C++
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.

Header: afx.h

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker