Memory debugger: Difference between revisions
Add FreeBSD and Solaris/illumos to Valgrind platforms |
imported>Neils51 replaced: it's → its, typo(s) fixed: time consuming → time-consuming |
||
| Line 3: | Line 3: | ||
{{Program execution}} | {{Program execution}} | ||
A '''memory debugger''' is a [[debugger]] for finding software memory problems such as [[memory leak]]s and [[buffer overflow]]s. | A '''memory debugger''' is a [[debugger]] for finding software memory problems such as [[memory leak]]s and [[buffer overflow]]s. These are due to [[Software bug|bugs]] related to the allocation and deallocation of [[dynamic memory]]. Programs written in languages that have [[Garbage collection (computer science)|garbage collection]], such as [[managed code]], might also need memory debuggers, e.g. for memory leaks due to "living" references in collections. | ||
==Overview== | ==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 (e.g. [[Valgrind]]) 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. | 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 (e.g. [[Valgrind]]) 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.<ref>{{cite web|url=http://www.computerworld.com/article/3003957/linux/review-5-memory-debuggers-for-linux-coding.html|access-date=August 24, 2017|title=Review: 5 memory debuggers for Linux coding|date=20 November 2015}}</ref> | 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.<ref>{{cite web|url=http://www.computerworld.com/article/3003957/linux/review-5-memory-debuggers-for-linux-coding.html|access-date=August 24, 2017|title=Review: 5 memory debuggers for Linux coding|date=20 November 2015}}</ref> | ||
As abnormally high memory utilization can be a contributing factor in [[software aging]], memory debuggers can help programmers to avoid [[software anomaly|software anomalies]] that would exhaust the computer system memory, thus ensuring high reliability of the software even for long [[run time (program lifecycle phase)|runtimes]]. | As abnormally high memory utilization can be a contributing factor in [[software aging]], memory debuggers can help programmers to avoid [[software anomaly|software anomalies]] that would exhaust the computer system memory, thus ensuring high reliability of the software even for long [[run time (program lifecycle phase)|runtimes]]. | ||
==Comparison to static analyzer== | ==Comparison to static analyzer== | ||
Some [[List of tools for static code analysis|static analysis tools]] can also help find memory errors. Memory debuggers operate as part of an application while | Some [[List of tools for static code analysis|static analysis tools]] can also help find memory errors. Memory debuggers operate as part of an application while its [[Execution (computing)|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.<ref>{{cite web|url=https://software.intel.com/en-us/inspector-user-guide-windows-dynamic-analysis-vs-static-analysis|access-date=August 24, 2017|title=Dynamic Analysis vs. Static Analysis}}</ref> | ||
==List of memory debugging tools== | ==List of memory debugging tools== | ||
Revision as of 12:51, 3 June 2025
Template:Short description Template:More citations needed Template:Program execution
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 (e.g. Valgrind) 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.[1]
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.[2]
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.
| Name | OS | License | Languages | Technique |
|---|---|---|---|---|
| AddressSanitizer | Linux, Mac OS | Free/open source (LLVM) | C, C++, Rust | Compile-time instrumentation (available in Clang and GCC) and specialized library |
| Allinea DDT | Linux, Blue Gene | Template:Proprietary commercial | C, C++ and F90. Also for parallel programs on supercomputers | Runtime - through dynamic linking |
| AQtime | Windows (Visual Studio, Embarcadero IDEs) | Template:Proprietary commercial | .NET, C++, Java, Silverlight, JScript, VBScript[3] | Runtime |
| Bcheck | Solaris | |||
| BoundsChecker | Windows (Visual Studio) | Template:Proprietary commercial | C++ | Runtime intercepts or compile-time |
| Daikon | Unix, Windows, Mac OS X[4] | Free/open source[5] | Java, C/C++, Perl, and Eiffel[4] | Runtime dynamic invariant detection |
| Debug_new | (general technique) | (general technique) | C++ | Compile-time override |
| Deleaker | Windows (standalone, and plugins for Visual Studio, RAD Studio, Qt Creator, CLion) | Template:Proprietary commercial | C++, .Net, Delphi | Runtime intercepts |
| dmalloc | Template:Any | Free/open source (ISC License) | C | Compile-time override |
| Template:Section link | Android, Linux, Windows | Free/open source (LGPL and BSD) | Template:Any | Runtime intercepts |
| Electric Fence | Unix | Template:GPL-lic | C, C++ | Compile-time override |
| FASTMM4 | Windows | Template:GPL-lic | Delphi | Compile-time override |
| IBM Rational Purify | Unix, Windows | Template:Proprietary commercial | C++, Java, .NET | Runtime |
| Insure++ | Windows (Visual Studio plugin), Unix | Template:Proprietary commercial | C, C++ | source code instrumentation |
| Intel Inspector | Windows (Visual Studio), Linux | Template:Proprietary commercial | C, C++, Fortran | Runtime |
| libcwd | Linux (gcc) | Free/open source | C, C++ | Compile-time override |
| libumem | Solaris | Bundled with Solaris | Link-time override | |
| Memwatch | Template:Any (programming library) | Free/open source | C | Compile-time override |
| mtrace | Template:Varies | Template:LGPL-lic | GNU C library | Built-in, outputs accesses |
| MTuner | Template:Varies | Free | C, C++ | Runtime intercepts, Link-time override (MSVC, Clang and GCC), Leak detection |
| Oracle Solaris Studio (formerly Sun Studio Runtime Checking) | Linux, Solaris | Proprietary freeware | C, C++, Fortran | |
| OLIVER (APT international) | MVS, MVS/EXA, DOS/VSE | Template:Proprietary software | IBM Assembler | Runtime intercepts, Hypervisor - Type 2 |
| TotalView | Unix, Mac OS X | Template:Proprietary commercial | C, C++, Fortran | Runtime |
| Template:Section link | Linux, FreeBSD, Solaris/illumos, Mac OS, Android | Template:GPL-lic | Template:Any | Runtime intercepts |
| WinDbg | Windows | Template:Proprietary freeware | C, C++, .NET, Python | Runtime |
See also
- Profiling (computer programming)
- List of performance analysis tools
- Debugger
- Runtime error detection
- Software testing
- Software engineering
- Computer programming
- Core dump
References
- Michael C. Daconta: C++ Pointers and Dynamic Memory Management, John Wiley & Sons, Template:ISBN
- Andrew Koenig: C Traps and Pitfalls, Addison-Wesley, Template:ISBN
External links
- "Hunting Memory Bugs" by Ivan Skytte Jørgensen
- "Comparison of Free Memory Checkers" by Jean-Philippe Martin Template:Full citation needed