Memory Diagnostics

·To enable or disable memory diagnostics:

Call the AfxEnableMemoryTracking to enable or disable the diagnostic memory allocator. Since memory diagnostics are on by default in the Debug library, you will typically use this function to temporarily turn off memory diagnostics to speed program execution and reduce diagnostic output.

·To select specific memory diagnostic features with afxMemDF:

If you want more precise control over the memory diagnostic features, you can selectively turn inidividual memory diagnostic features on and off by setting the value of the Microsoft Foundation Class Library global variable afxMemDF. This variable can have the following values as specified by the enumerated type AfxMemDF:

  Value Meaning

  allocMemDF Turn on debugging allocator (default).
  delayFreeMemDF Delay freeing memory when calling delete or free. This will cause maximum memory stress for your program.
  checkAlwaysMemDF Call AfxCheckMemory every time memory is allocated or freed.

These possible values can be used in combination by performing a logical-OR operation, as shown here:

afxMemDF |= delayFreeMemDF | checkAlwaysMemDF;