VLD使用方法

1.到官网上下载http://vld.codeplex.com/releases 上下载最新的VLD程序。

2.一路安装。

3.然后在项目属性里面,【VC++ Directories】->【Include Directories】中添加VLD的安装目录中的src。

4.另外,【Linker】->【Additional Library Directories】中添加VLD的安装目录下的lib文件所在的目录。如果你的VS是32版本的话,那就添加Win32目录,否则添加Win64目录.

5.然后点击编译,运行。

测试程序如下:

// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include "vld.h"


void test()
{
char* pChar = new char[20];
//delete[] pChar;
return;
}


int _tmain(int argc, _TCHAR* argv[])
{
test();
return 0;
}

那么我们可以看到VLD在VS输出窗口输出的内容。

-------------------------华丽的分割线-------------------------------------------

Visual Leak Detector Version 2.2.3 installed.
WARNING: Visual Leak Detector detected memory leaks!
---------- Block 1 at 0x00552290: 20 bytes ----------
  Call Stack:
    e:\test\consoleapplication1\consoleapplication1\consoleapplication1.cpp (10): ConsoleApplication1.exe!test + 0x7 bytes
    e:\test\consoleapplication1\consoleapplication1\consoleapplication1.cpp (18): ConsoleApplication1.exe!wmain
    f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (533): ConsoleApplication1.exe!__tmainCRTStartup + 0x19 bytes
    f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (377): ConsoleApplication1.exe!wmainCRTStartup
    0x7507336A (File and line number not available): kernel32.dll!BaseThreadInitThunk + 0x12 bytes
    0x770F92B2 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x63 bytes
    0x770F9285 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x36 bytes
  Data:
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD                                                  ........ ........




Visual Leak Detector detected 1 memory leak (56 bytes).
Largest number used: 56 bytes.
Total allocations: 56 bytes.
Visual Leak Detector is now exiting.


--------------------------------------------------------------------------

双击vld提示的内存泄漏的行号信息,那么我们就可以直接定位到有内存泄漏的地方。



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值