[Original] What is memory leakage? Attached memory leak detection tool
1. What is memory leakage?
In computer science, memory leakage refers to the failure to release memory that is no longer used due to negligence or errors. Memory leakage does not mean that the internal memory disappears physically, but that after the application allocates a certain segment of memory, the memory is wasted due to design errors and the loss of control over this segment of memory.
Generally, memory leakage refers to heap memory leakage. Heap memory refers to the memory allocated by the program from the heap, which is of any size (the size of the memory block can be determined during the running period). The released memory must be displayed after use. Applications generally use functions such as malloc, realloc, and new to allocate a block of memory from the heap. after use, the program must call free or delete to release the block. Otherwise, this memory cannot be used again, so we can say this memory is leaked.
Binary Memory leakage classification:
1. Frequent Memory leakage. Code with Memory leakage will be executed multiple times, resulting in a memory leak each time it is executed.
2. Occasional Memory leakage. Memory leakage occurs only in certain environments or operations. The frequency and frequency are relative. For a specific environment, unexpected events may become frequent. Therefore, the test environment and test method are crucial for detecting memory leaks.
3. One-time memory leakage. The code with Memory leakage is executed only once, or due to algorithm defects, there will always be only one piece of Memory leakage. For example, if the memory is allocated in a singleton constructor, the memory is not released in the destructor. The Singleton class only has one instance, So memory leakage only occurs once.
4. Implicit Memory leakage. The program continuously allocates memory during the running process, but it does not release the memory until it ends. Strictly speaking, there is no memory leakage because the program releases all requested memory. However, if a server program needs to run for several days, weeks, or even months, failing to release the memory in time may eventually exhaust all the system memory. Therefore, we call this type of Memory leakage an implicit memory leak.
Three memory leak detection tools:
1. ccmalloc-simple memory leakage and malloc debugging libraries for C and C ++ programs in Linux and Solaris.
2. dmalloc-Debug malloc library.
3. electric fence-malloc () debugging library written by Bruce perens in the Linux distribution.
4. leaky-programs for detecting memory leaks in Linux.
5. leaktracer-Linux, Solaris, and HP-UX tracking and analysis of memory leaks in C ++ programs.
6. memwatch-written by Johan Lindh, is an open-source C language memory error detection tool mainly through the GCC precessor.
7. valgrind-debugging and profiling Linux programs, aiming at programs written in C and C ++.
8. kcachegrind-a visualization tool for the profiling data generated by cachegrind and calltree.
9. Leak Monitor-a Firefox extension that can identify Firefox-related leakage types.
10. ie Leak Detector (drip/ie sieve)-drip and IE sieve leak detectors help Web developers improve dynamic web page performance through reports to avoid Memory leakage due to limited IE.
11. Windows leaks detector-detects any resource leakage (memory, handle, etc.) in any Win32 application and calls hooks Based on win APIs.
12. SAP memory analyzer-is an open-source Java memory analysis software that can be used to help find memory leaks in Java programs. It is easy to find large volumes of memory and verify who is occupying it all the time, it is based on Eclipse RCP (rich client platform) and can download the RCP independent version or Eclipse plug-in.
13. dtrace-dynamically tracks Dynamic Tracing. It is an open-source software that can run on a Unix-like platform. Users can dynamically detect operating system kernels and user processes, to more accurately grasp the system resource usage, improve system performance, reduce support costs, and make effective adjustments.
14. IBM Rational purifyplus-helps developers identify performance and reliability errors in C/C ++, managed. net, Java, and VB6 code. Purifyplus combines features such as memory error and leak detection, Application Performance description, and code coverage analysis into a single and complete toolkit.
15. parasoft insure ++-an automatic error detection tool for C/C ++ applications. It can automatically monitor C/C ++ programs, memory Corruption, memory leakage, pointer errors, and I/O errors are detected. By using a series of unique technologies (such as SCI technology and mutation testing), we thoroughly inspect and test our code, precisely locate the correct location of errors, and provide detailed diagnostic information. Can be used as a plug-in for Microsoft Visual C ++.
16. compuware devpartner for Visual C ++ boundschecker suite-runtime error detection and debugging tool software designed for C ++ developers. Run as a plug-in for Microsoft Visual Studio and C ++ 6.0.
17. Electric software glowcode-including memory leakage check, code profiler, function call tracking, and other functions. Provides complete error diagnosis and runtime performance analysis toolkit for C ++ and. NET developers.
18. compuware devpartner Java edition-includes Java memory detection, code coverage testing, code performance testing, thread deadlock, distributed applications, and other major functional modules.
19. Quest Jprobe-analyze Java Memory leakage.
20. ej-technologies jprofiler-a full-featured Java profiling tool dedicated to analyzing j2se and J2EE applications. It combines CPU, thread, and memory analysis in a powerful application. Jprofiler provides many ide integration and application server integration functions. Jprofiler's intuitive GUI allows you to find performance bottlenecks, capture memory leaks, and solve execution thread problems. 4.3.2 registration code: A-G666 # 76114f-1olm9mv1i5uuly #0126
21. Bea jrockit-used to diagnose Java memory leaks and identify the root cause. It is specially designed for Intel platforms and optimized to achieve the highest performance on Intel hardware.
22. SciTech software AB. Net memory profiler-find memory leaks and optimize memory usage for C #, VB. NET, or other. net programs.
23. yourkit. Net & JAVA profiler-industry-leading Java and. Net program performance analysis tools.
24. The next generation replacement product of the performance profiling and memory debugging toolset of the award-winning products of automatedqa-automatedqa, which supports Microsoft, Borland, Intel, Compaq and GNU compilers. You can generate comprehensive and detailed reports for. NET and Windows programs to help you easily isolate and eliminate the performance and memory/resource leakage problems contained in the Code. Supports. NET 1.0, 1.1, 2.0, 3.0, and Windows 32/64-bit applications.
25. javaScript Memory Leak Detector-a debugging tool released by Microsoft's global product development-Europe team (gpvdf) to detect memory leaks in JavaScript code, runs as a plug-in of the IE series.
Appendix 4:
How to Use LoadRunner to test the system memory leakage?