次の方法で共有


Memory Diagnostics

Before you can use the memory diagnostics facilities, you must enable diagnostic tracing.

To enable or disable memory diagnostics

  • Call the global function AfxEnableMemoryTracking to enable or disable the diagnostic memory allocator. Because memory diagnostics are on by default in the debug library, you will typically use this function to temporarily turn them off, which increases program execution speed and reduces 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 individual memory diagnostic features on and off by setting the value of the MFC global variable afxMemDF. This variable can have the following values as specified by the enumerated type AfxMemDF:

    Value Meaning
    allocMemDF Turn on diagnostic memory allocator (default).
    delayFreeMemDF Delay freeing memory when calling delete or free until program exits. This will cause your program to allocate the maximum possible amount of memory.
    checkAlwaysMemDF Call AfxCheckMemory every time memory is allocated or freed.

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

    afxMemDF | delayFreeMemDF | checkAlwaysMemDF;