<p>What memory leak detectors have people had a good experience with?</p>

<p>Here is a summary of the answers so far:</p>

<p><a href="http://valgrind.org/" rel="noreferrer">Valgrind</a> - Instrumentation framework for building dynamic analysis tools.</p>

<p><a href="http://directory.fsf.org/project/ElectricFence/" rel="noreferrer">Electric Fence</a> - A tool that works with GDB</p>

<p><a href="http://splint.org/" rel="noreferrer">Splint</a> - Annotation-Assisted Lightweight Static Checking</p>

<p><a href="http://www.glowcode.com/" rel="noreferrer">Glow Code</a> - This is a complete real-time performance and memory profiler for Windows and .NET programmers who develop applications with C++, C#, or any .NET Framework</p>

<p>Also see this <a href="https://stackoverflow.com/questions/45627/how-do-you-detectavoid-memory-leaks-in-your-unmanaged-code">stackoverflow post</a>.</p>

[{'answer_id': 53429, 'author': 'hazzen', 'author_id': 5066, 'author_profile': 'https://Stackoverflow.com/users/5066', 'pm_score': 4, 'selected': False, 'text': '<p><a href="http://valgrind.org/" rel="nofollow noreferrer">Valgrind</a> under linux is fairly good; I have no experience under Windows with this.</p>\n'}, {'answer_id': 53434, 'author': '1800 INFORMATION', 'author_id': 3146, 'author_profile': 'https://Stackoverflow.com/users/3146', 'pm_score': 1, 'selected': False, 'text': '<p>I\'ve had minimal love for any memory leak detectors. Typically there are far too many false positives for them to be of any use. I would recommend these two as beiong the least intrusive:</p>\n\n<p><a href="http://www.glowcode.com/" rel="nofollow noreferrer">GlowCode</a></p>\n\n<p><a href="http://msdn.microsoft.com/en-us/library/974tc9t1(VS.80).aspx" rel="nofollow noreferrer">Debug heap</a></p>\n'}, {'answer_id': 53443, 'author': 'Ben Collins', 'author_id': 3279, 'author_profile': 'https://Stackoverflow.com/users/3279', 'pm_score': 2, 'selected': False, 'text': '<p>lint (very similar open-source tool called <a href="http://splint.org/" rel="nofollow noreferrer">splint</a>)</p>\n'}, {'answer_id': 53445, 'author': 'nlucaroni', 'author_id': 157, 'author_profile': 'https://Stackoverflow.com/users/157', 'pm_score': 5, 'selected': True, 'text': '<p>second the <a href="http://valgrind.org/" rel="noreferrer">valgrind</a>... and I\'ll add <a href="http://directory.fsf.org/project/ElectricFence/" rel="noreferrer">electric fence</a>.</p>\n'}, {'answer_id': 53462, 'author': 'Gishu', 'author_id': 1695, 'author_profile': 'https://Stackoverflow.com/users/1695', 'pm_score': 2, 'selected': False, 'text': '<p>Painful but if you had to use one..<br>\nI\'d recommend the <a href="http://www.borland.com/products/devpartner/read/" rel="nofollow noreferrer">DevPartner BoundsChecker</a> suite.. that\'s what people at my workplace use for this purpose. Paid n proprietary.. not freeware.</p>\n'}, {'answer_id': 53486, 'author': 'Marcel', 'author_id': 131, 'author_profile': 'https://Stackoverflow.com/users/131', 'pm_score': 0, 'selected': False, 'text': '<p>At university when I was doing most things under Unix Solaris I used <a href="http://www.gnu.org/software/gdb/" rel="nofollow noreferrer">gdb</a>. </p>\n\n<p>However I would go with <a href="http://valgrind.org/" rel="nofollow noreferrer">valgrind</a> under Linux.</p>\n'}, {'answer_id': 54975, 'author': 'Alan H', 'author_id': 3807, 'author_profile': 'https://Stackoverflow.com/users/3807', 'pm_score': -1, 'selected': False, 'text': "<p>I'll second the valgrind as an external tool for memory leaks.<br>\nBut, for most of the problems I've had to solve I've always used internally built tools.  Sometimes the external tools have too much overhead or are too complicated to set up.</p>\n\n<p>Why use already written code when you can write your own :)</p>\n\n<p>I joke, but sometimes you need something simple and it's faster to write it yourself.\nUsually I just replace calls to malloc() and free() with functions that keep better\ntrack of who allocates what.  Most of my problems seem to be someone forgot to free and this helps to solve that problem.</p>\n\n<p>It really depends on where the leak is, and if you knew that, then you would not need any tools.  But if you have some insight into where you think it's leaking, then put in your own instrumentation and see if it helps you. </p>\n"}, {'answer_id': 55803, 'author': 'David L Morris', 'author_id': 3137, 'author_profile': 'https://Stackoverflow.com/users/3137', 'pm_score': 1, 'selected': False, 'text': '<p>For Win32 debugging of memory leaks I have had very good experiences with the plain old CRT Debug Heap, that comes as a lib with Visual C.</p>\n\n<p>In a Debug build malloc (et al) get redefined as _malloc_dbg (et al) and there are other calls to retrieve results, which are all undefined if _DEBUG is not set.  It sets up all sorts of boundary guards on the heap, and allows you to diplay the results at any time.</p>\n\n<p>I had a few false positives when I was witting some time routines that messed with the library run time allocations until I discovered _CRT_BLOCK.</p>\n\n<p>I had to produce first DOS, then Win32 console and services that would run for ever.  As far as I know there are no memory leaks, and in at least one place the code run for two years unattended before the monitor on the PC failed (though the PC was fine!).</p>\n'}, {'answer_id': 136183, 'author': 'djsadinoff', 'author_id': 22369, 'author_profile': 'https://Stackoverflow.com/users/22369', 'pm_score': 0, 'selected': False, 'text': '<p>The granddaddy of these tools is the commercial, closed-source <a href="http://unicomsi.com/products/purifyplus/" rel="nofollow noreferrer">Purify</a> tool, which was sold to IBM and then to UNICOM</p>\n\n<p>Parasoft\'s <a href="http://en.wikipedia.org/wiki/Insure%2B%2B" rel="nofollow noreferrer">Insure++</a> (source code instrumentation) and valgrind (open source) are the two other real competitors. </p>\n\n<p>Trivia:  the original author of Purify, Reed Hastings, went on to found NetFlix.</p>\n'}, {'answer_id': 136333, 'author': 'Thorsten79', 'author_id': 19734, 'author_profile': 'https://Stackoverflow.com/users/19734', 'pm_score': 2, 'selected': False, 'text': '<p>If you have the money: <a href="http://www-01.ibm.com/software/awdtools/purify/" rel="nofollow noreferrer">IBM Rational Purify</a> is an extremely powerful industry-strength memory leak and memory corruption detector for C/C++. Exists for Windows, Solaris and Linux. If you\'re linux-only and want a cheap solution, go for Valgrind.</p>\n'}, {'answer_id': 276821, 'author': 'Artelius', 'author_id': 31945, 'author_profile': 'https://Stackoverflow.com/users/31945', 'pm_score': 2, 'selected': False, 'text': '<p><a href="http://gcc.gnu.org/wiki/Mudflap_Pointer_Debugging" rel="nofollow noreferrer">Mudflap</a> for gcc! It actually compiles the checks into the executable. Just add</p>\n\n<pre><code>-fmudflap -lmudflap\n</code></pre>\n\n<p>to your gcc flags.</p>\n'}, {'answer_id': 281061, 'author': 'Chris Morley', 'author_id': 36034, 'author_profile': 'https://Stackoverflow.com/users/36034', 'pm_score': 1, 'selected': False, 'text': '<p>On Windows, I have used <a href="http://vld.codeplex.com" rel="nofollow noreferrer">Visual Leak Detector</a>. Integrates with VC++, easy to use (just include a header and set LIB to find the lib), open source, free to use FTW.</p>\n'}, {'answer_id': 281877, 'author': 'Ben Combee', 'author_id': 1323, 'author_profile': 'https://Stackoverflow.com/users/1323', 'pm_score': 2, 'selected': False, 'text': '<p>Also worth using if you\'re on Linux using glibc is the built-in debug heap code.  To use it, link with <strong>-lmcheck</strong> or define (and export) the <strong>MALLOC_CHECK_</strong> environment variable with the value 1, 2, or 3.  <a href="http://www.gnu.org/software/libtool/manual/libc/Heap-Consistency-Checking.html" rel="nofollow noreferrer">The glibc manual provides more information.</a></p>\n\n<p>This mode is most useful for detecting double-frees, and it often finds writes outside the allocated memory area when doing a free.  I don\'t think it reports leaked memory.</p>\n'}, {'answer_id': 11202703, 'author': 'Ira Baxter', 'author_id': 120163, 'author_profile': 'https://Stackoverflow.com/users/120163', 'pm_score': -1, 'selected': False, 'text': '<p>Our <a href="http://www.semanticdesigns.com/Products/MemorySafety" rel="nofollow">CheckPointer</a> tool can do this for GNU C 3/4 and, MS dialects of C, and GreenHills C.  It can find memory management problems that Valgrind cannot.</p>\n\n<p>If your code simply leaks, on exit CheckPointer will tell you where all the unfreed memory was allocated.</p>\n'}, {'answer_id': 12480154, 'author': 'Felix', 'author_id': 1680728, 'author_profile': 'https://Stackoverflow.com/users/1680728', 'pm_score': 2, 'selected': False, 'text': '<p>I had quite some hits with <a href="http://sourceforge.net/apps/mediawiki/cppcheck/index.php?title=Main_Page#Cppcheck_-_A_tool_for_static_C.2FC.2B.2B_code_analysis" rel="nofollow">cppcheck</a>, which does static analysis only. It is open source and has a command line interface (I did not use it in any other way).</p>\n'}, {'answer_id': 32984657, 'author': 'arrowd', 'author_id': 637669, 'author_profile': 'https://Stackoverflow.com/users/637669', 'pm_score': 0, 'selected': False, 'text': '<p>No one mentioned <a href="http://clang.llvm.org/docs/MemorySanitizer.html" rel="nofollow">clang\'s MSan</a>, which is quite powerful. It is officially supported on Linux only, though.</p>\n'}, {'answer_id': 40408045, 'author': 'TarmoPikaro', 'author_id': 2338477, 'author_profile': 'https://Stackoverflow.com/users/2338477', 'pm_score': 0, 'selected': False, 'text': '<p>This question maybe old, but I\'ll answer it anyway - maybe my answer will help someone to find their memory leaks.</p>\n\n<p>This is my own project - I\'ve put it as open source code:</p>\n\n<p><a href="https://sourceforge.net/projects/diagnostic/" rel="nofollow noreferrer">https://sourceforge.net/projects/diagnostic/</a></p>\n\n<p>Windows 32 &amp; 64-bit platforms are supported, native and mixed mode callstacks are supported.</p>\n\n<p>.NET garbage collection is not supported. (C++ cli\'s gcnew or C#\'s new)</p>\n\n<p>It high performance tool, and does not require any integration (unless you really want to integrate it).</p>\n\n<p>Complete manual can be found here:</p>\n\n<p><a href="http://diagnostic.sourceforge.net/index.html" rel="nofollow noreferrer">http://diagnostic.sourceforge.net/index.html</a></p>\n\n<p>Don\'t be afraid of how much it actually detects leaks it your process. It catches memory leaks from whole process. Analyze only biggest leaks, not all.</p>\n'}]
['https://Stackoverflow.com/questions/53426', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2064/']