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:

#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.
    #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)

转载于:https://www.cnblogs.com/GuiltySpark/p/4951123.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值