DEBUG_NEW is just a MACRO, which is usually defined as:
#define DEBUG_NEW new(__FILE__, __LINE__) #define new DEBUG_NEW
So, wherever you use new , it can also keep track of the file and line numbers that you can use to detect memory leaks in your program.
And __FILE__ , __LINE__ are predefined macros that evaluate the file name and line number respectively, where you use them!
Read the following article, which explains how to use DEBUG_NEW with other interesting macros, very nicely:
Cross-platform memory leak detector
From Wikpedia ,
Debug_new refers to a technique in C ++ for overloading and / or overriding a new operator and a delete operator to intercept memory allocation and release calls and thus debug the program to use memory. Often includes a macro definition called DEBUG_NEW and does something like new (_FILE_, _LINE_) to write file / line information to the selection. . Microsoft Visual C ++ uses this method in Microsoft Fundamentals. There are some ways to extend this method to avoid using macro redefinition, the ability to display file / line information about some platforms. There are many inherent to this limitation method. It applies only to C ++ and cannot catch memory leaks using C functions such as malloc. However, it can be very easy to use and also very fast compared to some more complete memory debugging solutions.
Nawaz
source share