This documentation is archived and is not being maintained.

The CRT Debug Heap

This topic applies to:


Visual Basic




Web Developer


Topic does not applyTopic does not applyTopic does not apply

Native only

Topic does not apply

Pro, Premium, and Ultimate

Topic does not applyTopic does not applyTopic does not apply

Native only

Topic does not apply

This section provides a detailed look at the CRT debug heap.

Memory Management and the Debug Heap

Describes the Debug versions of heap functions. These functions solve two of the most difficult memory allocation problems: overwriting the end of an allocated buffer and memory leaks (failing to free allocations after they are no longer needed).

Types of Blocks on the Debug Heap

Describes the five allocation types that memory blocks are assigned to in the debug heap. These allocation types are tracked and reported differently for purposes of leak detection and state reporting.

The Debug Heap

Provides information on using the debug heap. Information includes which calls resolve to Debug versions, what happens when you free a memory block, which debug features have to be accessed from within your code, steps to change _crtDbgFlag bit fields to create a new state for the flag, and a code example that illustrates turning on automatic leak detection and turning off checking for blocks of type _CRT_BLOCK.

The Debug Heap from C++

Discusses the Debug versions of the C++ new and delete operators and the effects of using _CRTDBG_MAP_ALLOC.

Heap State Reporting Functions

Describes the _CrtMemState structure, which you can use to capture a summary snapshot of the state of the heap. This topic also lists the CRT functions that report the state and contents of the heap and use the information to help detect memory leaks and other problems.

Tracking Heap Allocation Requests

Contains ways to identify the specific heap allocation call that went bad.

CRT Debugging Techniques

Links you to debugging techniques for the C Run-Time Library, including: using the CRT Debug Library, macros for reporting, differences between malloc and _malloc_dbg, writing debug hook functions, and the CRT debug heap.