Visual c ++ Memory leakage detection-VLD tool usage instructions.

Source: Internet
Author: User

Visual c ++Memory leakage detection-VLDTool instructions

I.VLDTool Overview

Visual Leak Detector ( VLD ) Is used Visual c ++ Free memory leak detection tool. He has the following features: You can obtain the call stack of the memory leak point. If you can, you can also obtain the file and row number of the memory leak point;   Obtain the full data of the leaked memory; You can set the Memory Leak report level, which is open-source and free of charge.

 

II.VLDDownload

Http://www.codeproject.com/tools/visualleakdetector.asp

Attached to this articleVld1.0.

 

III.VLDInstall

Method 1:

Decompress the package to obtain VLD. H, vldapi. H, VLD. Lib, vldmt. Lib, vldmtdll. Lib, dbghelp. dll . Set . H Copy files Visual c ++ By default Include Directory . Lib Copy files Visual c ++ By default Lib Directory Dbghelp. dll Copy to yourProgramThe installation is complete.

Method 2:

VLD. h, vldapi. h, VLD. lib, vldmt. lib, vldmtdll. lib, dbghelp. DLL and other files. . h file and . lib copy the file to the directory where the project file you want to detect is located (only for this project), and dbghelp. DLL copy to the running directory of your program. The installation is complete.

 

4.VLDUse

. CPP File Inclusion VLD. h . The following example illustrates ( ) :

1.Add the header file:

2.Compile:

3.InDebugRun in: ViewVCOutput Information:

Location of Memory leakage

 

4.ViewVCOutput Information:

"Warning: Visual leak detector detected meory leaks! "

 

5.If no memory leakage occurs, the output information is:

"No memory leaks detected"

 

 

5.Appendix

1. Testing files

# Include"VLD. H"

 

# Include"Iostream. H"

# Include"Stdio. H"

# Include"Stdlib. H"

# Include"String. H"

 

VoidFunction1 (Char*P)

{

Char * pTMP = new char [255];

Memset(PTMP, 0x0,255 );

Strncpy(PTMP,P, 255 );

// Delete pTMP;

}

 

IntFunction2 (Void)

{

Char Acstring[] ="This is test! ";

Function1 (Acstring);

Return1;

}

 

VoidFunction3 (Void)

{

Function2 ();

}

IntMain (Void)

{

Cout<"Begin .............."<Endl;

 

Function3 ();

Cout<"End ................"<Endl;

Return1;

}

 

2.Vld1.0Toolkit

 

 

3 . about Linux Memory leakage, valgrind tool for detection.

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.