Please note that User Registration has been temporarily disabled due to a recent increase in automated registrations. If anyone needs an account, please request one here: RequestAccount. Thanks for your patience!--Wmat (talk)
Please email User:Wmat if you experience any issues with the Request Account form.

Difference between revisions of "Memory Debuggers"

Jump to: navigation, search
m (remove [])
(Tutorials or Overviews)
Line 49: Line 49:
== Tutorials or Overviews ==
== Tutorials or Overviews ==
* [ Memory Leak Detection in Embedded Systems] by Cal Erickson, Linux Journal, September 2002
* [ Memory Leak Detection in Embedded Systems] by Cal Erickson, Linux Journal, September 2002
** This mentions mentions mtrace, memwatch and dmalloc
** This article mentions mtrace, memwatch and dmalloc

Revision as of 23:30, 15 July 2010

Several tools exist for finding memory leaks or for reporting individual memory allocations of a program.


mtrace is a builtin part of glibc which allows detection of memory leaks caused by unbalanced malloc/free calls. To use it, the program is modified to call mtrace() and muntrace() to start and stop tracing of allocations. A log file is created, which can then be scanned by the 'mtrace' Perl script. The 'mtrace' program lists only unbalanced allocations. If source is available it can show the source line where the problem occurred. mtrace can be used on both C and C++ programs.

See the mtrace wikipedia article for more information.


memwatch is a program that not only detects malloc and free errors but also reads and writes beyond the allocated space (buffer over and under-runs). To use it, you modify the source to include the memwatch code, which provides replacements for malloc and free.

Some things that memwatch does not catch are writing to an address that has been freed and reading data from outside the allocated memory.


mpatrol appears to be like memwatch.



"The debug memory allocation or dmalloc library has been designed as a drop in replacement for the system's malloc, realloc, calloc, free and other memory management routines while providing powerful debugging facilities configurable at runtime. These facilities include such things as memory-leak tracking, fence-post write detection, file/line number reporting, and general logging of statistics."

This library can be used without modifying the existing program, and uses environment variables to control it's operation and set of issues to log.

It's home page is at:

See Cal Erickson's article (link below, page 2) for information about using this system.


dbgmem looks like another dynamic library replacement tool, similar to dmalloc (but possibly having less features)



valgrind does dynamic source code modification to instrument the program, and provides a number of memory problem detection tools and profiling tools. Unfortunately, as of July 2010 it is only available for x86 and ppc64 architecture platforms.

See Valgrind

Electric Fence

See Electric Fence

Tutorials or Overviews