Skip to content

Latest commit

 

History

History
56 lines (36 loc) · 3.26 KB

crtdumpmemoryleaks.md

File metadata and controls

56 lines (36 loc) · 3.26 KB
title description ms.date api_name api_location api_type topic_type f1_keywords helpviewer_keywords
_CrtDumpMemoryLeaks
Learn more about: _CrtDumpMemoryLeaks
11/04/2016
_CrtDumpMemoryLeaks
msvcrt.dll
msvcr80.dll
msvcr90.dll
msvcr100.dll
msvcr100_clr0400.dll
msvcr110.dll
msvcr110_clr0400.dll
msvcr120.dll
msvcr120_clr0400.dll
ucrtbase.dll
DLLExport
apiref
CRTDBG_LEAK_CHECK_DF
CRTDBG_CHECK_CRT_DF
_CRTDBG_LEAK_CHECK_DF
CrtDumpMemoryLeaks
_CrtDumpMemoryLeaks
_CRTDBG_CHECK_CRT_DF
CrtDumpMemoryLeaks function
CRTDBG_LEAK_CHECK_DF macro
_CRTDBG_LEAK_CHECK_DF macro
_CrtDumpMemoryLeaks function
CRTDBG_CHECK_CRT_DF macro
_CRTDBG_CHECK_CRT_DF macro

_CrtDumpMemoryLeaks

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

Syntax

int _CrtDumpMemoryLeaks( void );

Return value

_CrtDumpMemoryLeaks returns TRUE if a memory leak is found. Otherwise, the function returns FALSE.

Remarks

The _CrtDumpMemoryLeaks function 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 isn't defined, calls to _CrtDumpMemoryLeaks are removed during preprocessing.

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

_CrtDumpMemoryLeaks calls _CrtMemCheckpoint to obtain the current state of the heap and then scans the state for blocks that haven't been freed. When an unfreed block is encountered, _CrtDumpMemoryLeaks calls _CrtMemDumpAllObjectsSince to dump information for all the objects allocated in the heap from the start of program execution.

By default, internal C run-time blocks (_CRT_BLOCK) aren't included in memory dump operations. The _CrtSetDbgFlag function can be used 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 more information about how memory blocks are allocated, initialized, and managed in the debug version of the base heap, see CRT debug heap details.

Requirements

Routine Required header
_CrtDumpMemoryLeaks <crtdbg.h>

For more compatibility information, see Compatibility.

Libraries

Debug versions of C run-time libraries only.

Example

For a sample of how to use _CrtDumpMemoryLeaks, see crt_dbg1.

See also

Debug routines