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"

From eLinux.org
Jump to: navigation, search
(Tutorials or Overviews)
(valgrind doesn't use source code)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
Several tools exist for finding memory leaks or for reporting individual memory allocations
 
Several tools exist for finding memory leaks or for reporting individual memory allocations
of a program.
+
of a program. These tools help analyze memory usage patterns, detect unbalanced allocations and frees, report buffer over- and under-runs, etc.
 
+
 
+
 
+
  
 
=== mtrace ===
 
=== mtrace ===
Line 38: Line 35:
  
 
=== valgrind ===
 
=== valgrind ===
valgrind does dynamic source code modification to instrument the program, and provides a number
+
valgrind does dynamic binary instrumentation to analyze the program, and provides a number
 
of memory problem detection tools and profiling tools.  Unfortunately, as of July 2010 it is
 
of memory problem detection tools and profiling tools.  Unfortunately, as of July 2010 it is
 
only available for x86 and ppc64 architecture platforms.
 
only available for x86 and ppc64 architecture platforms.
Line 50: Line 47:
 
* [http://www.linuxjournal.com/article/6059 Memory Leak Detection in Embedded Systems] by Cal Erickson, Linux Journal, September 2002
 
* [http://www.linuxjournal.com/article/6059 Memory Leak Detection in Embedded Systems] by Cal Erickson, Linux Journal, September 2002
 
** This article mentions mtrace, memwatch and dmalloc
 
** This article mentions mtrace, memwatch and dmalloc
 +
 +
[[Category:Development Tools]]

Latest revision as of 20:38, 10 August 2011

Several tools exist for finding memory leaks or for reporting individual memory allocations of a program. These tools help analyze memory usage patterns, detect unbalanced allocations and frees, report buffer over- and under-runs, etc.

mtrace

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

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

mpatrol appears to be like memwatch.

See http://mpatrol.sourceforge.net/

dmalloc

"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: http://dmalloc.com/

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

dbgmem

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

See http://dbgmem.sourceforge.net/

valgrind

valgrind does dynamic binary instrumentation to analyze 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