Udostępnij za pośrednictwem


Memory Leak Detection in MFC

This topic applies to:

Edition

Visual Basic

C#

C++

Web Developer

Express

Topic does not apply Topic does not apply

Native only

Topic does not apply

Standard

Topic does not apply Topic does not apply

Native only

Topic does not apply

Pro and Team

Topic does not apply Topic does not apply

Native only

Topic does not apply

Table legend:

Topic applies

Applies

Topic does not apply

Does not apply

Topic applies but command hidden by default

Command or commands hidden by default.

MFC provides classes and functions for detecting memory that is allocated but never deallocated.

In This Section

  • Tracking Memory Allocations
    Discusses the DEBUG_NEW macro, which you can use to locate memory leaks. Information includes considerations in Debug and Release versions, defining the macro in your source files, and object dumps.

  • Enabling Memory Diagnostics
    Provides steps for enabling diagnostic tracing and selecting specific memory diagnostic features with afxMemDF (for more precise control).

  • Taking Memory Snapshots
    Shows how to take snapshots of memory to help locate memory leaks.

  • Viewing Memory Statistics
    Describes the CMemoryState::Difference function (compares memory) and the CMemoryState::DumpStatistics (prints memory statistics) and provides code examples.

  • Object Dumps
    Provides information on object dumps, including the DumpAllObjectsSince function, example code, and considerations, as well as interpreting and customizing object dumps.

  • Detecting and Isolating Memory Leaks
    How to use the C run-time library to detect memory leaks.

  • MFC Debugging Techniques
    Links you to debugging techniques for MFC programs, including: afxDebugBreak, the TRACE macro, detecting memory leaks in MFC, MFC assertions, and reducing the size of MFC Debug builds.

  • Debugging Visual C++
    Discusses some common debugging problems and techniques for C and C++ applications.