Visual C + + memory leak detection, available with the VLD tool.
Vld:visual Leak Detector. VLD is a free memory leak detection Tool for Visual C + +. His features are: You can get the memory leak point of the call stack, if possible, you can also get the file and line number, you can get full data leakage memory, you can set the level of memory leak report, and is open source free.
Official website: http://vld.codeplex.com/releases/view/82311
Steps to use:
1) Download VLD toolkit on official website.
2) after decompression to get vld.h, vldapi.h, Vld.lib, Vldmt.lib, Vldmtdll.lib, Dbghelp.dll and other documents.
3) Copy the. h file and the. lib file to the directory where you want to detect the project file (for this project only), and copy the Dbghelp.dll to the running directory of your program.
4) include Vld.h in the. cpp file that contains the entry function.
Linux memory leaks can be detected using the Valgrind tool.
Valgrind is a set of simulation-based program debugging and analysis tools running on Linux that contains a kernel-a software-synthesized CPU, and a series of gadgets, each of which can perform a task-debugging, analysis, or testing. Valgrind can detect memory leaks and memory violations.
Valgrind Memory Detection Tool Memcheck, used to detect memory problems in the program, all memory read and write will be detected, all calls to malloc ()/free ()/new/delete will be captured.
Therefore, it can detect the following problems:
1) use of uninitialized memory.
2) Read/write the memory block after release.
3) read/write memory blocks that exceed malloc allocations.
4) Read/write inappropriate memory blocks in the stack.
5) memory leaks, pointers to a piece of memory are lost forever.
6) incorrect malloc/free or New/delete match.
7) The DST and src pointers overlap in the memcpy () correlation function.
These problems are often the most vexing problem for C + + programmers, and Memcheck is very helpful here.
Program crash location method.
Reference article: http://blog.csdn.net/frankiewang008/article/details/8021411
1) crash in the development environment.
At this point, you can go directly to the debugger to locate the error location, the debugger to load the corresponding PDB file to locate the error location.
2) crash in test environment.
Remote debugging techniques can be used to locate errors. Microsoft Visual Studio has a remote debugging tool from Debugger.
Steps.
A. Send the remote debugger to the machine to be tested.
B. Configure the remote debugger to support long-distance debugging.
C. Develop the machine open visual Studio for remote debugging. Debug->attach to Process.
Configuration: Transport for remote,qualifier input to remote machine IP.
3) crash in user environment.
This kind of environment is the most difficult. The positioning steps are as follows.
A. Key steps in the development process add print logs to facilitate problem locating.
B. Crash callback registration, blocking Windows program crashes.
Blocks windows from bringing exception handling callbacks.
Corresponds to Api:setunhandledexceptionfilter.
C. In callback processing, the output crashes the cause, crashes the memory address, and crashes the stack.
Crash information is printed in the exception callback function and output to the file under Program execution directory
The function prototype of the exception handling callback:
LONG WINAPI callbackdebuginfo (exception_pointers *pexception);
D. Project output map file.
Map file Logger global symbols, source files and code line number information, is the entire program engineering information static text. You can open a map file with a text reading tool such as Ultra Edit or Notepad.
In VC, open the Project Settings Options page, select the C + + tab, and in the bottom Project options, enter:/zd, and then select the Link tab and select the Generate mapfile check box. In the bottom of the Project options, enter:/mapinfo:lines, which indicates that the row information is added when the map file is generated.
Finally compile the map file can be generated, in the debug or release directory of the project to find the map file just generated, the file name is "project name. Map".
E. Use the map file to locate the crash function.
The key information used is the crash address. The map file contains the generated addresses for each function.
F. Use the map code line to locate the crash line interval.
The map file contains the generated address of the line of code that can be used for row positioning.
Summary of C + + technical issues-15th, what are the methods for memory leaks, what are the ways to locate a crash