Identify Memory Leaks in Visual CPP Applications(VLD内存泄漏检测工具)

原文地址:http://www.codeproject.com/Articles/1045847/Identify-Memory-Leaks-in-Visual-CPP-Applications

基于CPOL License

Identify Memory Leaks in Visual CPP Applications

Visual Leak Detector (VLD) is an easy to use memory leak detection system. The installation package can be downloaded from here.

After installation, it can be used with any C/C++ project simply by adding the following line to the code:

Hide   Copy Code

#include <vld.h>

When the program is executed under the Visual Studio debugger, Visual Leak Detector will output a memory leak report of the executed segment of the code, at the end of the debugging session. If memory leaks are detected, this report will point to the exact locations in the code segment, which allocated the leaked memory block.

The header file can be easily isolated from the rest of the source codes by guarding it with the pre-processor directive block. It can be made further user friendly by defining a separate Visual Studio build configuration for VLD. The steps are as follows:

  1. Include VLD header files(s) protected by a pre-processor directive.

    Hide   Copy Code

    #ifdef _VLD_DEBUG
    #include <vld.h> //For memory leak detection.
    #endif  //_VLD_DEBUG
  2. Create a VLD specific Build Configuration for development purposes. Detailed steps to create a Build Configuration are available here.
  3. Under the new Build Configuration (example VLD_Debug), define the pre-processor directive which enables VLD specific headers.
    1. Right click on the project on Visual Studio Solution Explorer & select Properties. This will open the Property Page of the project.
    2. Expand the Configuration Properties node.
    3. Expand C\C++ node.
    4. Select Preprocessor. Enter preprocessor definition (example. "_VLD_DEBUG").
    5. Add the location of the vld.h header file to "includes" directory path of this configuration.
  4. Select VLD specific Build Configuration for development purposes.

References

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

时间: 2024-08-10 16:59:46

Identify Memory Leaks in Visual CPP Applications(VLD内存泄漏检测工具)的相关文章

vld(Visual Leak Detector) 内存泄露检测工具,Visual C++ 2008-2015

原文: https://vld.codeplex.com/ Visual Leak Detector 是一款专用于Visual C++的内存泄漏检测工具,它免费,开源,且鲁棒性高. VLD很容易使用: 1. 安装完vld后,只要告诉Visual C++哪里去找到它的头文件和库.(下载地址:https://vld.codeplex.com) 2. 然后您只要在你的c/c++工程中加上下面这一行代码,就可以使用vld了:#include <vld.h> 您的工程在Visual Studio deb

Cocos开发中性能优化工具介绍之Visual Studio内存泄漏检测工具——Visual Leak Detector

那么在Windows下有什么好的内存泄漏检测工具呢?微软提供Visual Studio开发工具本身没有什么太好的内存泄漏检测功能,我们可以使用第三方工具Visual Leak Detector(以下简称vld). vld工具是VC++环境下一款小巧易用.免费开源的内存泄漏检测工具,vld可以显示导致内存泄漏的完整内存分配调用堆栈.vld的检测报告能够对每个内存泄漏点提供完整的堆栈跟踪,并且包含其源文件及行号信息. 安装过程是,先在到地址http://vld.codeplex.com/下载vld安

内存泄漏检测工具VLD在VS2010中的使用举例

Visual LeakDetector(VLD)是一款用于Visual C++的免费的内存泄露检测工具.它的特点有:(1).它是免费开源的,采用LGPL协议:(2).它可以得到内存泄露点的调用堆栈,可以获取到所在文件及行号:(3).它可以得到泄露内存的完整数据:(4).它可以设置内存泄露报告的级别. 默认情况下,只有在Debug模式下才会启用VLD的功能. 在使用的时候只要将VLD的头文件和lib文件放在工程文件中即可. 在需要检测内存泄露的源文件中添加#include "vld.h"

在VS2017中配置VLD(Visual Leak Detector)内存泄漏检测工具

首先在官方下载VLD 下载地址: https://github-production-release-asset-2e65be.s3.amazonaws.com/566097/583de30e-b359-11e7-99d7-0f1fb50d7654?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190221%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Da

内存泄漏检测工具Visual Leak Detector

1,下载地址 http://vld.codeplex.com/releases/view/619330 2,使用方法 http://www.codeproject.com/Articles/9815/Visual-Leak-Detector-Enhanced-Memory-Leak-Detectio

vld(Visual Leak Detector) 内存泄露检测工具

初识Visual Leak Detector 灵活自由是C/C++语言的一大特色,而这也为C/C++程序员出了一个难题.当程序越来越复 杂时,内存的管理也会变得越加复杂,稍有不慎就会出现内存问题.内存泄漏是最常见的内存问题之一.内存泄漏如果不是很严重,在短时间内对程序不会有太大的 影响,这也使得内存泄漏问题有很强的隐蔽性,不容易被发现.然而不管内存泄漏多么轻微,当程序长时间运行时,其破坏力是惊人的,从性能下降到内存耗尽,甚 至会影响到其他程序的正常运行.另外内存问题的一个共同特点是,内存问题本身

_CrtSetBreakAlloc简单内存泄漏检测方法,解决Detected memory leaks!问题

我的环境是: XP SP2 . VS2003 最近在一个项目中,程序退出后都出现内存泄漏: Detected memory leaks! Dumping objects -> {98500} normal block at 0x05785AD0, 152 bytes long. Data: << N N x 7 > 3C AC 4E 10 00 00 00 00 BC A4 4E 10 78 B6 37 00 Object dump complete.   而且每次退出都是一样的.

简单内存泄漏检测方法 解决 Detected memory leaks! 问题

最近在一个项目中,程序退出后都出现内存泄漏: Detected memory leaks! Dumping objects -> {98500} normal block at 0x05785AD0, 152 bytes long. Data: << N N x 7 > 3C AC 4E 10 00 00 00 00 BC A4 4E 10 78 B6 37 00 Object dump complete.   而且每次退出都是一样的.泄漏的内存块都是98500. 解决方法: 1.

自己实现简易的内存泄露检测工具VLD

有一个很著名的内存泄露检测工具Visual leak detected想必大家都不陌生,但今天我们可以自己写一个简易版的.哈哈,自己动手,丰衣足食有木有!!! 它的原理就是我们重载了操作符new和delete,当用new开辟空间的时候,就讲这块空间串到我们定义的结构体MEMNode形成的链表中,(这是老师的写法,在main程序结束时,用check_vld()函数检测有没有内存泄露)但我觉得,如果我们动态开辟了一个对象,在它的析构函数里用delete释放的话,这种方法就不太可行.因为析构函数只有到