VLD (visual leak detector), a tool used in VC to detect memory leaks)

Source: Internet
Author: User

Flexibility and freedom are a major feature of the C language, but this feature also brings unavoidable side effects, such as memory leakage. As we all know, the problem of Memory leakage is complicated. When a program runs normally, you cannot see any exceptions, but it runs for a long time or when a specific operation is repeated multiple times under a specific condition, it is exposed. Therefore, memory leakage is often hard to discover and solve.

Visual Leak Detector (VLD) is a free memory leak detection tool for Visual C ++.
Lesser General Public License) protocol is open source, so it is safe to use VLD without worrying about copyright issues.

Vctester is a white-box testing tool suitable for VC code. With its Script driver and script pile function, it can easily initiate various tests, because memory leakage usually occurs under specific operations, vctester is used in combination with VLD. vctester simulates various application scenarios. VLD detects whether memory leakage occurs in these scenarios.

Use VLD

Download the VLD zip package from the website. The current maximum version is V1.0. decompress the package to obtain the VLD. h. vldapi. h. VLD. lib, vldmt. lib, vldmtdll. lib, dbghelp. DLL files, put all these. copy the H header file to the default include directory of VC, and copy all. copy the Lib file to the default lib directory of VC, and the installation is complete.

VLD is easy to use. You only need to include the VLD. h header file in the CPP or C file that contains the entry function. This include statement must be placed at the beginning. If the current project defines a pre-compiled head file (such as stdafx. h), put it in "# include
<Stdafx. h>. After the program is compiled normally and run in debug mode, check the output window of VC when the program is running.
Leak detector is now exiting. "A printed message. If the current program has no memory leakage before this condition information," no memory leaks detected. "Information printing, but if there is memory leakage, there will be similar information printing:

C: "vctester21" sample "vc6" samplemain. C (80): Main

Crt0.c (206): maincrtstartup

0x7c816fd7 (file and line number not available): registerwaitforinputidle

Data:

CD ................

Visual leak detector detected 1 memory leak.

This information indicates the function and source file number where the current Memory leakage occurs, and the address, length, and current memory value of the leaked memory block. Double-click the prompt message indicating the source code line. VC automatically jumps to the corresponding code line, so we can easily know which line has an error.

It can be seen that VLD is easy to use. If you are interested in its implementation principle, you can read the VLD source code or refer to dofty's article: using Visual
Leak detector detects Memory leakage.


Tip: http://www.cnblogs.com/dwjaissk/archive/2007/11/08/952927.html

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.