INtime SDK Help
_CrtMemDifference
INtime SDK v7.1 > About INtime > Other system libraries > Heaps and memory pools > Using the Debug Heap > Heap State Reporting Functions > _CrtMemDifference

Compares two memory states and returns their differences (debug version only).

int _CrtMemDifference (
    _CrtMemState * state, 
    const _CrtMemState * oldState, 
    const _CrtMemState * newState
);

Parameters

state
Pointer to a _CrtMemState structure that stores the differences between the two memory states (returned).
oldState
Pointer to an earlier memory state (_CrtMemState structure).
newState
Pointer to a later memory state (_CrtMemState structure).

Remarks

_CrtMemDifference compares oldState and newState and stores their differences in state, which the application uses to detect memory leaks and other memory problems. When _DEBUG is not defined, preprocessing removes calls to _CrtMemDifference.

newState and oldState must each be a valid pointer to a _CrtMemState structure, defined in Crtdbg.h and filled in by _CrtMemCheckpoint, before calling _CrtMemDifference. state 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 state. 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 largest amount ever allocated at once for the two states and the difference between total allocations for the two states are also stored in state.

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.

Return Values

TRUE
Memory states are different
FALSE
Memory states are the same.

Requirements

Versions Defined in Include Link to
INtime 3.13 intime/rt/include/crtdbg.h crtdbg.h clib.lib
   
See Also