C ++ Memory Leak Detection Library

I am looking for a memory leak detection library. Something like I would just include it in the source code, then it should start to detect. External programs might be good, but I was looking for a library that could be associated with an executable.
This is me looking for Windows.

+6
c ++ memory
source share
6 answers

For me, it has been a very long time the best tool: http://www.paulnettle.com/pub/FluidStudios/MemoryManagers/Fluid_Studios_Memory_Manager.zip Just include 1 header file and you're done with it :)

+2
source share

I can offer Visual Leak Detector , much easier to use than the built-in Visual Studio.

+4
source share

You can use some methods in your code to detect a memory leak. The most common and easiest way to detect is to define a macro, say DEBUG_NEW, and use it with predefined macros such as __FILE__ and __LINE__ to find a memory leak in your code. These predefined macros tell you the file number and line of memory leaks.

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 can be used 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.

+4
source share

Visual Studio has this feature on Windows. See http://msdn.microsoft.com/en-us/library/e5ewb1h3(v=VS.90).aspx . Under linux, I don't know if such things exist, but valgrind is really useful to find all memory problems (not only leaks, but also invalid reads, for example).

+2
source share

If you use VC ++, this functionality is built-in. See Searching for memory leaks using the CRT library for non-MFC applications, and Detecting memory leaks in MFC for MFC applications.

0
source share

Complementing the above, I can advise several good programs: ^) As an example? it would be nice to use deleaker for windows.

0
source share

All Articles