Use Visual Leak Detector (VLD)

Source: Internet
Author: User

Visual c ++ has built-in memory leakage detection tools, but has limited functions. VLD is quite powerful. It can locate the file and row number, locate the location of Memory leakage very accurately, andFree and open-source!

You only need to put the header file and Lib file of VLD in the project file.

You can also set it once, so you don't have to reset it for the new project. This section only describes the setting method in Visual Studio 2003/2005. VC ++ 6.0 is similar:

    1. Open tools-> options-> projects and solutions-> VC ++ directories;
    2. Click the include files drop-down list and add the include folder in the VLD installation directory at the end;
    3. Similarly, click the Lib drop-down list to add the VLD Lib;
    4. Add
    5. # Include "VLD. h"

      The sequence does not matter, but it must not be before some pre-compiled files (such as stdafx. h ). I added it to the end of stdafx. h file.

    6. Copy all the dllfiles in the dllfolder under the installation directory to the project debugdirectory and the location generated by debug .exe. Click debug-> start debugging for debugging.ProgramIn the output window, the files, row numbers, and content leaked by memory during the program running are displayed.

Sample detection result:

---------- Block 2715024 at 0x04d8a368: 512 bytes ---------- call Stack: D: \ kangzj \ Documents \ Visual Studio 2005 \ projects \ rsip. root \ readtiff \ segmentflag. CPP (56): csegmentflag: getflagfromarray D: \ kangzj \ Documents \ Visual Studio 2005 \ projects \ rsip. root \ readtiff \ wholeclassdlg. CPP (495): segmentthreadproc F: \ dd \ vctools \ vc7libs \ ship \ atlmfc \ SRC \ MFC \ thrdcore. CPP (109): _ afxthreadentry F: \ Dd \ vctools \ crt_bld \ self_x86 \ CRT \ SRC \ threadex. C (348): _ callthreadstartex F: \ dd \ vctools \ crt_bld \ self_x86 \ CRT \ SRC \ threadex. C (331): _ threadstartex 0x7c80b729 (file and line number not available): getmodulefilenamea data: 3C 3C 3C 3C 3C 3C 3C 3C 45 45 45 45 & lt; & lt; <eeeee EEE eeeeeeee> & gt; & gt; 3E 3E 3E 3E 3E 3E 3E 3E 3E 3E & Gt; & gt; & gt; 3E 3E 3E 38 38 38 38 2B 2B 2B 2B 12 12 12 & gt; 888 8 ++... 12 12 12 12 12 12 12 12 12 12 12 2B 2B 2B 2B ........... +++ 2B 2B 2B 2B 2B 2B 2B 2B 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 77777777 77777777 37 37 37 37 37 37 37 37 37 37 21 21 21 21 21 21 77777777 77 !!!!!! 29 29 29 29 3A 3A 3A 3A 3A 3A 3A 3A 3A 3A 3A 3A 3A )))):::::::::::: 3A 3A 3A 3A 3A 3A 44 44 44 44 44 44 44 ::::::: d dddddddd 41 41 41 44 44 44 44 44 44 44 44 41 41 41 aaaadddd ddddddddaa 41 41 41 41 41 3D 3D 3D 3D 3D 3D aaaaaa ==== ======== 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D ==================== 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D ==================== 3D 3 D 3D 3D 3D 3D 29 29 29 29 29 35 35 35 35 ======= )))))) 5555 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 55555555 55555555 35 35 35 35 35 35 35 35 35 35 35 35 29 29 55555555 555555 )) 29 29 29 29 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 )))) 2222 22222222 32 32 32 32 32 32 32 32 32 32 43 32 32 32 22222222 222cc222 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 cccccccccccc 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 cccccccc 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f ???????? ???????? 3f 3f 3f 3f 3f 3f 3f 1C 1C 1C 1C 46 46 46 46 ???????. .... FFFF 46 46 46 46 46 40 40 40 40 40 40 40 40 40 40 40 ffffff @ 40 40 40 40 40 40 40 46 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 @ f @ 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 @@@@ </eeeee>

more detailed instructions are provided for the installer.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.