Debug New
   HOME

TheInfoList



OR:

{{context, date=February 2020 Debug_new refers to a technique in C++ to overload and/or redefine operator new and operator delete in order to intercept the memory allocation and deallocation calls, and thus debug a program for memory usage. It often involves defining a macro named DEBUG_NEW, and makes new become something like new(__FILE__, __LINE__) to record the file/line information on allocation. Microsoft
Visual C++ Microsoft Visual C++ (MSVC) is a compiler for the C, C++, C++/CLI and C++/CX programming languages by Microsoft. MSVC is proprietary software; it was originally a standalone product but later became a part of Visual Studio and made available ...
uses this technique in its
Microsoft Foundation Classes Microsoft Foundation Class Library (MFC) is a C++ Object-oriented programming, object-oriented Library (computer science), library for developing desktop applications for Windows. MFC was introduced by Microsoft in 1992 and quickly gained wides ...
. There are some ways to extend this method to avoid using macro redefinition while still able to display the file/line information on some platforms. There are many inherent limitations to this method. It applies only to C++, and cannot catch
memory leak In computer science, a memory leak is a type of resource leak that occurs when a computer program incorrectly manages memory allocations in a way that memory which is no longer needed is not released. A memory leak may also happen when an objec ...
s by C functions like
malloc C dynamic memory allocation refers to performing manual memory management for dynamic memory allocation in the C programming language via a group of functions in the C standard library, namely , , , and . The C++ programming language includ ...
. However, it can be very simple to use and also very fast, when compared to some more complete
memory debugger A memory debugger is a debugger for finding software memory problems such as memory leaks and buffer overflows. These are due to bugs related to the allocation and deallocation of dynamic memory. Programs written in languages that have garba ...
solutions.


See also

*
Memory debugger A memory debugger is a debugger for finding software memory problems such as memory leaks and buffer overflows. These are due to bugs related to the allocation and deallocation of dynamic memory. Programs written in languages that have garba ...


External links


A Cross-Platform Memory Leak DetectorDEBUG_NEW (MFC)
Software testing tools Memory management software Articles with underscores in the title