Compares two memory states and returns their differences (debug version only).
int _CrtMemDifference( _CrtMemState *stateDiff, const _CrtMemState *oldState, const _CrtMemState *newState );
- Pointer to a _CrtMemState structure that will be used to store the differences between the two memory states (returned).
- Pointer to an earlier memory state (_CrtMemState structure).
- Pointer to a later memory state (_CrtMemState structure).
If the memory states are significantly different, _CrtMemDifference returns TRUE. Otherwise, the function returns FALSE.
The _CrtMemDifference function compares oldState and newState and stores their differences in stateDiff, which can then be used by the application to detect memory leaks and other memory problems. When _DEBUG is not defined, calls to _CrtMemDifference are removed during preprocessing.
newState and oldState must each be a valid pointer to a _CrtMemState structure, defined in CRTDBG.H, that has been filled in by _CrtMemCheckpoint before calling _CrtMemDifference. stateDiff must be a pointer to a previously allocated instance of the _CrtMemState structure.
_CrtMemDifference compares the _CrtMemState field values of the blocks in oldState to those in newState and stores the result in stateDiff. When the number of allocated block types or total number of allocated blocks for each type differs between the two memory states, the states are said to be significantly different. The difference between the two states' high water count and total allocations is also stored in stateDiff.
By default, internal C run-time blocks (_CRT_BLOCK) are not included in memory state operations. The _CrtSetDbgFlag function can be used to turn on the _CRTDBG_CHECK_CRT_DF bit of _crtDbgFlag to include these blocks in leak detection and other memory state operations. Freed memory blocks (_FREE_BLOCK) do not cause _CrtMemDifference to return TRUE.
For more information about heap state functions and the _CrtMemState structure, see Heap State Reporting Functions. For information about how memory blocks are allocated, initialized, and managed in the debug version of the base heap, see Memory Management and the Debug Heap.
|_CrtMemDifference||<crtdbg.h>||Win 98, Win Me, Win NT, Win 2000, Win XP|
For additional compatibility information, see Compatibility in the Introduction.
Debug versions of C run-time libraries only.
For a sample of how to use _CrtMemDifference, see crt_dbg1.