Memory debugger


A memory debugger is a debugger for finding software memory problems such as memory leaks and buffer overflows. These are due to bugs related to the allocation and deallocation of dynamic memory. Programs written in languages that have garbage collection, such as managed code, might also need memory debuggers, e.g. for memory leaks due to "living" references in collections.

Overview

Memory debuggers work by monitoring memory access, allocations, and deallocation of memory. Many memory debuggers require applications to be recompiled with special dynamic memory allocation libraries, whose APIs are mostly compatible with conventional dynamic memory allocation libraries, or else use dynamic linking. Electric Fence is such a debugger which debugs memory allocation with malloc. Some memory debuggers work by running the executable in a virtual machine-like environment, monitoring memory access, allocation and deallocation so that no recompilation with special memory allocation libraries is required.
Finding memory issues such as leaks can be extremely time-consuming as they may not manifest themselves except under certain conditions. Using a tool to detect memory misuse makes the process much faster and easier.
As abnormally high memory utilization can be a contributing factor in software aging, memory debuggers can help programmers to avoid software anomalies that would exhaust the computer system memory, thus ensuring high reliability of the software even for long runtimes.

Comparison to static analyzer

Some static analysis tools can also help find memory errors. Memory debuggers operate as part of an application while its running while static code analysis is performed by analyzing the code without executing it. These different techniques will typically find different instances of problems, and using them both together yields the best result.

List of memory debugging tools

This is a list of tools useful for memory debugging. A profiler can be used in conjunction with a memory debugger.
NameOSLicenseLanguagesTechnique
AddressSanitizerLinux, Mac OSFree/open source C, C++, RustCompile-time instrumentation and specialized library
Allinea DDTLinux, Blue Gene commercialC, C++ and F90. Also for parallel programs on supercomputersRuntime - through dynamic linking
AQtimeWindows commercial.NET, C++, Java, Silverlight, JScript, VBScriptRuntime
BcheckSolaris
BoundsCheckerWindows commercialC++Runtime intercepts or compile-time
DaikonUnix, Windows, Mac OS XFree/open sourceJava, C/C++, Perl, and EiffelRuntime dynamic invariant detection
Debug_newC++Compile-time override
DeleakerWindows commercialC++,.Net, DelphiRuntime intercepts
dmallocFree/open source CCompile-time override
Android, Linux, WindowsFree/open source Runtime intercepts
Electric FenceUnixC, C++Compile-time override
FASTMM4WindowsDelphiCompile-time override
IBM Rational PurifyUnix, Windows commercialC++, Java,.NETRuntime
Insure++Windows, Unix commercialC, C++source code instrumentation
Intel InspectorWindows, Linux commercialC, C++, FortranRuntime
libcwdLinux Free/open sourceC, C++Compile-time override
libumemSolarisBundled with SolarisLink-time override
Memwatch Free/open sourceCCompile-time override
mtraceGNU C libraryBuilt-in, outputs accesses
MTunerC, C++Runtime intercepts, Link-time override, Leak detection
Oracle Solaris Studio Linux, SolarisProprietary freewareC, C++, Fortran
OLIVER MVS, MVS/EXA, DOS/VSE softwareIBM AssemblerRuntime intercepts, Hypervisor - Type 2
TotalViewUnix, Mac OS X commercialC, C++, FortranRuntime
Linux, FreeBSD, Solaris/illumos, Mac OS, AndroidRuntime intercepts
WinDbgWindows freewareC, C++,.NET, PythonRuntime