Memory Leak Detection in MFC
This topic applies to:
Pro and Team
MFC provides classes and functions for detecting memory that is allocated but never deallocated.
- 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.