DEBUG_NEW Macro

Syntax

#define new DEBUG_NEW

Remarks

Use to assist in finding memory leaks. You can use DEBUG_NEW everywhere in your program that you would ordinarily use the new operator to allocate heap storage.

In Debug mode (when the _DEBUG symbol is defined), DEBUG_NEW keeps track of the filename and line number for each object that it allocates. Then, when you use the DumpAllObjectsince member function of class CMemoryState, each object allocated with DEBUG_NEW is shown with the filename and line number where it was allocated.

To use DEBUG_NEW, insert the define directive shown in the syntax line above into your source files. Then wherever you use new, the preprocessor will insert DEBUG_NEW, and the class library does the rest. When you compile a release version of your program, DEBUG_NEW resolves to a simple new operation, and the filename and line number information is not generated.

Note:

In Release mode, DEBUG_NEW is defined to be the standard operator new, so you can leave DEBUG_NEW in your code.