The information in this article applies to:
SUMMARY
There is currently no documentation for the _afxBreakAlloc symbol defined
by MFC. However it can be extremely useful in finding the cause of memory
leaks in an application. This article explains how to use it.
MORE INFORMATIONThe Microsoft Foundation Classes have memory leak detection capabilities. When you execute a debug build of your application and you have used the AFX Trace Options Tool to Enable Tracing, MFC will report memory leaks when an object has been allocated (using operator new) but not deleted before the application exits. The default output in the debug window will look similar to this:
The number found in the braces ({n}) indicates the allocation number that
has occured. In the first object dump, it is obvious where the allocation
occured. But the second object dump does not give the file and line number
information, so it might be more difficult to track down the leak. However,
MFC has the capability of breaking on a particular allocation number by
using the _afxBreakAlloc symbol.
The _afxBreakAlloc variable is not available programmatically because it is defined as a static variable in the MFC source code module AFXMEM.CPP. However it can be set/modified using the debugger. We can find the point in our code in which memory allocation number 5 occured by setting _afxBreakAlloc equal to 5 before we get to that point in the code. To do so, follow these steps:
Additional query words: kbinf 1.00 1.50 2.00 2.10 2.50 3.00
Keywords : kbnokeyword kbCodeView kbDebug kbide kbMFC kbVC kbVC100 kbVC150 kbVC200 kbVC210 kbGrpDSTools |
Last Reviewed: July 29, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |