INtime SDK Help
_CrtCheckMemory
INtime SDK v6 > About INtime > Other system libraries > Heaps and memory pools > Using the Debug Heap > The Debug Heap > _CrtCheckMemory

Confirms the integrity of the memory blocks allocated in the debug heap (debug version only).

int _CrtCheckMemory (void);

Parameters

None.

Remarks

_CrtCheckMemory validates memory allocated by the debug heap manager by verifying the underlying base heap and inspecting every memory block. If the underlying base heap, debug header information, or overwrite buffers contain an error or memory inconsistency, _CrtCheckMemory generates a debug report with information that describes the error condition. When _DEBUG is not defined, preprocessing removes calls to _CrtCheckMemory.

You can control _CrtCheckMemory behavior by setting the bit fields of the _crtDbgFlag flag using _CrtSetDbgFlag. Turning the _CRTDBG_CHECK_ALWAYS_DF bit field ON results in calling _CrtCheckMemory every time a memory allocation operation is requested. Although this method slows down execution, it is useful for quickly catching errors. Turning the _CRTDBG_ALLOC_MEM_DF bit field OFF means _CrtCheckMemory does not verify the heap and immediately returns TRUE.

Because this function returns TRUE or FALSE, you can pass it to one of the _ASSERT macros to create a simple debugging error handling mechanism. The following example causes an assertion failure if corruption is detected in the heap:

_ASSERTE( _CrtCheckMemory( ) );

For more information about how to use _CrtCheckMemory with other debug functions, see Heap State Reporting Functions. For an overview of memory management and the debug heap, see Memory Management and the Debug Heap.

Return Values

TRUE
Success.
FALSE
Failure.

Requirements

Versions Defined in Include Link to
INtime 3.13 intime/rt/include/crtdbg.h

crtdbg.h

clib.lib
See Also