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

Dumps all the memory blocks in the debug heap when a memory leak occurs (debug version only).

int _CrtDumpMemoryLeaks (void);




_CrtDumpMemoryLeaks determines whether a memory leak has occurred since the start of program execution. When a leak is found, the debug header information for all the objects in the heap is dumped in a user-readable form. When _DEBUG is not defined, preprocessing removes calls to _CrtDumpMemoryLeaks.

_CrtDumpMemoryLeaks is frequently called at the end of program execution to verify that all memory allocated by the application is freed. You can automatically call the function at program termination by turning on the _CRTDBG_LEAK_CHECK_DF bit field of the _crtDbgFlag flag using _CrtSetDbgFlag.

_CrtDumpMemoryLeaks calls _CrtMemCheckpoint to obtain the heap's current state and then scans the state for blocks that are not freed. Upon encountering an unfreed block, _CrtDumpMemoryLeaks calls _CrtMemDumpAllObjectsSince to dump information for all objects allocated to the heap from the start of program execution.

By default, internal C run-time blocks (_CRT_BLOCK) are not included in memory dump operations. You can use _CrtSetDbgFlag to turn on the _CRTDBG_CHECK_CRT_DF bit of _crtDbgFlag to include these blocks in the leak detection process.

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

Success; a memory leak was found.
Failure. The function sets errno to one of these values:
EINVAL The pool is not a valid MPOOL.


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