Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
The CRT Debug Heap
 The Debug Heap from C++

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual Studio Debugger
The Debug Heap from C++

This topic applies to:

Edition

Visual Basic

C#

C++

Web Developer

Express

Topic does not applyTopic does not apply

Native only

Topic does not apply

Standard

Topic does not applyTopic does not apply

Native only

Topic does not apply

Pro and Team

Topic does not applyTopic does not apply

Native only

Topic does not apply

Table legend:

Topic applies

Applies

Topic does not apply

Does not apply

Topic applies but command hidden by default

Command or commands hidden by default.

In C++, you can call the Debug version of the new operator directly or create macros that replace the new operator in debug mode, as shown in the following example.

/* MyDbgNew.h
 Defines global operator new to allocate from
 client blocks
*/

#ifdef _DEBUG
   #define DEBUG_CLIENTBLOCK   new( _CLIENT_BLOCK, __FILE__, __LINE__)
#else
   #define DEBUG_CLIENTBLOCK
#endif // _DEBUG


/* MyApp.cpp
    Compile options needed: /Zi /D_DEBUG /MLd
 *            or use a
 *      Default Workspace for a Console Application to
 *      build a Debug version
*/

#include "crtdbg.h"
#include "mydbgnew.h"

#ifdef _DEBUG
#define new DEBUG_CLIENTBLOCK
#endif

int main( )   {
    char *p1;
    p1 =  new char[40];
    _CrtMemDumpAllObjectsSince( NULL );
}

The Debug version of the delete operator works with all block types and requires no changes in your program when you compile a Release version.

Other Resources

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker