Memory debugging and profiling tools

Boehm GC

The Boehm Garbage Collector is a conservative garbage collector that works by scanning memory for pointers to blocks of memory. While the Boehm GC is mostly meant for memory management, it also has a mode for leak detection in programs that manually free memory.


A comprehensive tool for tracking memory usage and finding memory leaks; it works on unmodified binaries by overriding the memory allocation functions with a LD_PRELOAD; it finds leaks by conservatively scanning memory. It is based on a a tool (memleak) which Keith Packard wrote while working on X. (No current link known.)


DMalloc is a very portable replacement for the C libraries memory allocation routines with a wide range of facilities for debugging and gathering statistics.


ElectricFence catches buffer overruns by guarding each block of memory with write-protected pages.

GNU C Library

The GNU C Library includes memory checking code that can be turned on by setting the environment variable MALLOC_CHECK_. See the info page documentation for more information on this feature. While fairly simple, it is effective at finding double-frees of memory, and has little overhead.


MemProf (by the author of this page) is a memory leak detector and profiler that works in a somewhat similar fashion to Debauch. It's notable feature is a nice graphical front end. MemProf works only on Linux.


Valgrind is a powerful tool that rewrites the object code of the application as it is executed to allow the detection of many sorts of memory errors, including such things as out-of-bounds writes and use of unitialized memory. One of the side-capabilities of Valgrind is the ability to detect leaked memory blocks by conservatively scanning memory.

By Owen Taylor <>

Return to my home page