The Microsoft Foundation Class Library (MFC) contains many diagnostic features to help debug your application during development. These features, especially those that track memory allocations, will slow down your program. Others, such as assertion testing, will cause your program to halt when erroneous conditions are encountered.
In a retail product, slow performance and program interruption are clearly unacceptable. For this reason, MFC provides a method for turning the debugging and diagnostic features on or off. When you are developing your program, you typically build a Win32 Debug version of your program and link with the debug version of MFC. Once the program is completed and debugged, you build a Win32 Release version and link with the release version of MFC.
*Note* Before you can use many of the MFC diagnostic features, you must enable diagnostic tracing by setting the afxTraceEnabled flag and customizing the afxTraceFlags to the level of detail you would like to see in trace messages. The easiest way to make these settings is with the TRACER.EXE utility.
Also see Knowledge Base article Q117326 “MFC Common Asserts, Causes, and Solutions.” Knowledge Base articles are available by connecting to:
Choose a Microsoft product (Visual C++), enter the article ID (Q-number) and click Retrieve Article.
The following debugging features are included in all classes derived from CObject in the debug version of the MFC:
Trace Output You can trace debugging output to evaluate argument validity. See the topic The TRACE Macro.
Check program assumptions Use the ASSERT macro to check program assumptions. See the topic The ASSERT Macro.
Use the AssertValid Macro You can perform a run-time check of an object’s internal consistency. See the topic Using the ASSERT_VALID Macro.
Track Memory Allocations Use the DEBUG_NEW macro to show where objects were allocated. See the topic Tracking Memory Allocations.
Detect Memory Leaks You can use memory diagnostics to detect memory leaks. See the topic Detecting Memory Leaks.