Visual C + + memory leak detection-VLD tool usage instructions [GO]

Source: Internet
Author: User

Visual C + + memory leak detection -VLD tool usage notes

A. VLD Tools Overview

visual Leak detector< Span style= "font-family: Song body; Color: #333333; font-size:12pt; " > (vld) is a visual c++< Span style= "font-family: Song body; Color: #333333; font-size:12pt; " > Free memory leak detection tool. His features are: can get the memory leak point of the call stack, if possible, you can also get the file and line number; Span style= "color: #333333; font-size:12pt; " >  can get full data of leaked memory;

two. VLD Download

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

This article is accompanied by a vld1.0 toolkit, which can be used after downloading the unpacked package.

three. VLD installation

Method One:

After decompression to getVld.h, vldapi.h, Vld.lib, Vldmt.lib, Vldmtdll.lib, Dbghelp.dlland other documents. Will. hCopy files toVisual C + +The defaultinclude.lib files copied to visual c++< Span style= "font-family: Song body; Color: #333333; font-size:12pt; " The default libdbghelp.dll< Span style= "font-family: Song body; Color: #333333; font-size:12pt; " > Copy to the running directory of your program, and the installation is complete

method two:

after decompression get vld.h, Vldapi.h, Vld.lib, Vldmt.lib, Vldmtdll.lib, Dbghelp.dll etc. Will .h files and .libdbghelp.dll copy it to the running directory of your program. The installation is complete.

Four. VLD use

in the .cppvld.h Yes, you can. The following is an example of source program See Appendix ) :

1. Add header file:

2. compiling:

3. run in debug mode: View The output information of the VC:

Where the memory leak resides

4. View VC output information:

"Warning:visual Leak Detector detected meory leaks!"

5. If there is no memory leak, the information for this output is:

"No Memory leaks detected"

Five. Appendix

1. Test file

#include "Vld.h"

#include "iostream.h"

#include "Stdio.h"

#include "Stdlib.h"

#include "String.h"

void Function1 (char *p)

{

Char *ptmp = new char[255];

memset(ptmp, 0x0, 255);

strncpy(ptmp, P, 255);

//delete ptmp;

}

int Function2 (void)

{

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

Function1 (acstring);

return 1;

}

void Function3 (void)

{

Function2 ();

}

int main (void)

{

cout << "Begin ......." << endl;

Function3 ();

cout << "End ........ " << endl;

return 1;

}

2. Vld1.0 Tool kit

3. For Linux memory leaks, you can use the valgrind tool for detection.

Visual C + + memory leak detection-VLD tool usage instructions [GO]

Related Article

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.