- 浏览: 258054 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (263)
- mysql (5)
- boost (6)
- 工具 (10)
- IT生活 (7)
- 多线程 (3)
- Ruby (15)
- php (2)
- MongoDB (39)
- 移动互联网 (2)
- 测试 (8)
- c++ (28)
- 书 (1)
- 网站 (3)
- 网络编程 (14)
- 开源软件 (1)
- 分布式计算 (1)
- 得得得 (1)
- php,wordpress (1)
- error (5)
- 编译 (2)
- 学习 (1)
- 杀毒软件 (1)
- dd (0)
- linux (21)
- 数据库 (1)
- STL (1)
- c++/c (5)
- 软件设计 (1)
- 操作系统 (4)
- 库 (2)
- win32 (1)
- s (0)
- openssl (1)
- perl (2)
- debug (1)
- windows (4)
- python (12)
- windows 防火墙 (1)
- vs (1)
- vim (2)
- vc (1)
- 浏览器插件的危害 (1)
- curl (0)
- 判断手机号码合法性的库 (0)
- 地址备注 (0)
- 安装 File::Slurp (1)
- cenos (2)
- shell (1)
- linunx (1)
- internet (1)
- software (1)
- widows (1)
- linux io (1)
- nginx (2)
- 算法 (2)
- google (1)
- protobuf (2)
- tengine (1)
- tools (1)
- lua (2)
- liunx (1)
- vcard (1)
- lua-iconv (1)
- 网络 (2)
- teat (0)
- ldconfig linux (0)
- awk (0)
- grep (0)
- windws (2)
- linux 命令 (1)
- tcp dump (1)
- vmware (1)
- question2answer (2)
- mongdb (1)
- 正则 (1)
- OCR (2)
- Windows Server (1)
最新评论
转:http://hi.baidu.com/gamecrack/blog/item/3fb88c446c1a482bcefca35b.html
最近将一个指纹匹配算法按照AFIS系统的接口标准做成dll上服务器测试,结果在进行200万人指纹的大库比对时出错了,通过分析发现是dll中存在内存泄露导致系统资源耗尽。虽然一次只有那么200kByte,但乘上200万这个基数也是不小。于是找来了两个工具来检测代码中的内存泄露:VLD和LeakDiag。
1.Visual Leak Detector 1.0 (VLD)
这是一个小巧内存检测工具,是为Visual C++用户设计的。其特色为:
简单易用,只需要在需要进行内存泄漏检测的的主程序代码中加入#include "VLD.h“,并将编译好的Lib文件放入默认的库目录,然后在Visual C++用Debug模式编译运行程序,程序运行结束后便可在Visual C++的输出窗口看到内存泄露检测结果。
通过宏定义控制测试行为,如报告的详略等。
支持Windows X64。
检测报告很直观,甚至能显示泄漏内存的内容。
下面是一段用于演示VLD功能的代码:
TestVLD.cpp
下面是Dll中被调用的函数代码
运行完毕之后的输出为:
WARNING: Visual Leak Detector detected memory leaks!
---------- Block 57 at 0x01C899D8: 16 bytes ----------
Call Stack:
f:\rtm\vctools\crt_bld\self_x86\crt\src\new2.cpp (27): operator new[]
f:\rtm\vctools\crt_bld\self_x86\crt\src\crt0.c (318): __tmainCRTStartup
f:\rtm\vctools\crt_bld\self_x86\crt\src\crt0.c (187): wmainCRTStartup
0x7D517D2A (File and line number not available): BaseProcessInitPostImport
Data:
64 6C 6C 20 6C 65 61 6B 69 6E 67 21 00 CD CD CD dll.leak ing!....
---------- Block 56 at 0x01C89990: 5 bytes ----------
Call Stack:
f:\rtm\vctools\crt_bld\self_x86\crt\src\new2.cpp (27): operator new[]
f:\rtm\vctools\crt_bld\self_x86\crt\src\crt0.c (318): __tmainCRTStartup
f:\rtm\vctools\crt_bld\self_x86\crt\src\crt0.c (187): wmainCRTStartup
0x7D517D2A (File and line number not available): BaseProcessInitPostImport
Data:
41 42 43 44 45 ABCDE... ........
---------- Block 55 at 0x01C89928: 40 bytes ----------
Call Stack:
f:\rtm\vctools\crt_bld\self_x86\crt\src\new2.cpp (27): operator new[]
f:\rtm\vctools\crt_bld\self_x86\crt\src\crt0.c (318): __tmainCRTStartup
f:\rtm\vctools\crt_bld\self_x86\crt\src\crt0.c (187): wmainCRTStartup
0x7D517D2A (File and line number not available): BaseProcessInitPostImport
Data:
00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00 ........ ........
04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 ........ ........
08 00 00 00 09 00 00 00 ........ ........
Visual Leak Detector detected 3 memory leaks.
可以看到,VLD检测出了分别在主程序函数t_main、leak5Bytes以及Dll.dll中dllLeak的内存泄漏,并显示了泄漏内存的内容。
2. LeakDiag
之前的VLD必须和源代码一起编译,若是遇到主程序源码不方便重新编译的情况,则可以选择使用LeakDiag。LeakDiag是微软的一款内存泄漏检测工具,鉴于已经有大牛写了比较详尽的使用说明,我就不再赘述,直接引用大牛的博客地址:
http://www.cppblog.com/sandy/archive/2008/08/18/59260.html
LeakDiag下载地址:
ftp://ftp.microsoft.com/PSS/Tools/Developer%20Support%20Tools/LeakDiag/
工具:
1. IBM Rational PurifyPlus是一套完整的运行时分析工具,旨在提高应用程序的可靠性和性能。PurifyPlus将内存错误和泄漏检测、应用程序性能描述、代码覆盖分析等功能组合在一个单一、完整的工具包中。
网站:
http://www-128.ibm.com/developerworks/rational/products/purifyplus
从这里可以得到 IBM Rational 的试用版(DVD),
http://www-128.ibm.com/developerworks/cn/offers/sek/index.html
2. BoundsChecker
BoundsChecker是一个C++运行时错误检测和调试工具。它通过在VisualStudio内自动化调试过程加速开发并且缩短上市的周期。BoundsChecker提供清楚,详细的程序错误分析,许多是对C++独有的并且在
static,stack和heap内存中检测和诊断错误,以及发现内存和资源的泄漏。
3. http://www.parasoft.com/
4. http://www.glowcode.com/
但是我在win7下安装LeakDiag 老是报 Error 1722, 很奇怪, 目前还没有解决。。。
Vld 不能显示调用堆栈内容,网上说程序路径不能有中文,但是我的路径都是英文的也,是不是我的vs2005是中文的,是不是这个原因呢。。。
最近将一个指纹匹配算法按照AFIS系统的接口标准做成dll上服务器测试,结果在进行200万人指纹的大库比对时出错了,通过分析发现是dll中存在内存泄露导致系统资源耗尽。虽然一次只有那么200kByte,但乘上200万这个基数也是不小。于是找来了两个工具来检测代码中的内存泄露:VLD和LeakDiag。
1.Visual Leak Detector 1.0 (VLD)
这是一个小巧内存检测工具,是为Visual C++用户设计的。其特色为:
简单易用,只需要在需要进行内存泄漏检测的的主程序代码中加入#include "VLD.h“,并将编译好的Lib文件放入默认的库目录,然后在Visual C++用Debug模式编译运行程序,程序运行结束后便可在Visual C++的输出窗口看到内存泄露检测结果。
通过宏定义控制测试行为,如报告的详略等。
支持Windows X64。
检测报告很直观,甚至能显示泄漏内存的内容。
下面是一段用于演示VLD功能的代码:
TestVLD.cpp
#include "stdafx.h" #include "vld.h" #include "afx.h" #include "string.h" typedef void(*FARPROC2)(int, char*); // 用于调用dll中函数的指针 void leak5Bytes(); // 泄漏5个字节内容为"ABCDE"内存 void leakInDll(); // 调用dll中会造成内存泄漏函数 int _tmain(int argc, _TCHAR* argv[]) { int * p = new int[10]; for (int i=0; i<10; ++i) p[i]=i; // 泄漏10个int的内存,内容分别为0到9 leak5Bytes(); // 泄漏5个字节内存 leakInDll(); // 调用dll中会造成内存泄泄漏的函数 return 0; } void leak5Bytes() { char * p = new char[5]; for (int i=0; i<5; ++i) p[i]='A'+i; // 泄漏的5个字节内存为"ABCDE" } void leakInDll() { char *p = new char[16]; strcpy(p, "dll leaking!"); // 调用dll函数,在dll中分配一个16字节的空间保存"dll leaking!",且不释放内存。 HMODULE hMod = LoadLibrary(_T("Dll.dll")); if (hMod) { FARPROC2 hLeakInDll = (FARPROC2) GetProcAddress(hMod, "dllLeak"); hLeakInDll(16, p); } }
下面是Dll中被调用的函数代码
void dllLeak(int n, char * st) { char *p = new char[n]; for (int i=0; i<n; ++i) p[i] = st[i]; }
运行完毕之后的输出为:
WARNING: Visual Leak Detector detected memory leaks!
---------- Block 57 at 0x01C899D8: 16 bytes ----------
Call Stack:
f:\rtm\vctools\crt_bld\self_x86\crt\src\new2.cpp (27): operator new[]
f:\rtm\vctools\crt_bld\self_x86\crt\src\crt0.c (318): __tmainCRTStartup
f:\rtm\vctools\crt_bld\self_x86\crt\src\crt0.c (187): wmainCRTStartup
0x7D517D2A (File and line number not available): BaseProcessInitPostImport
Data:
64 6C 6C 20 6C 65 61 6B 69 6E 67 21 00 CD CD CD dll.leak ing!....
---------- Block 56 at 0x01C89990: 5 bytes ----------
Call Stack:
f:\rtm\vctools\crt_bld\self_x86\crt\src\new2.cpp (27): operator new[]
f:\rtm\vctools\crt_bld\self_x86\crt\src\crt0.c (318): __tmainCRTStartup
f:\rtm\vctools\crt_bld\self_x86\crt\src\crt0.c (187): wmainCRTStartup
0x7D517D2A (File and line number not available): BaseProcessInitPostImport
Data:
41 42 43 44 45 ABCDE... ........
---------- Block 55 at 0x01C89928: 40 bytes ----------
Call Stack:
f:\rtm\vctools\crt_bld\self_x86\crt\src\new2.cpp (27): operator new[]
f:\rtm\vctools\crt_bld\self_x86\crt\src\crt0.c (318): __tmainCRTStartup
f:\rtm\vctools\crt_bld\self_x86\crt\src\crt0.c (187): wmainCRTStartup
0x7D517D2A (File and line number not available): BaseProcessInitPostImport
Data:
00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00 ........ ........
04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 ........ ........
08 00 00 00 09 00 00 00 ........ ........
Visual Leak Detector detected 3 memory leaks.
可以看到,VLD检测出了分别在主程序函数t_main、leak5Bytes以及Dll.dll中dllLeak的内存泄漏,并显示了泄漏内存的内容。
2. LeakDiag
之前的VLD必须和源代码一起编译,若是遇到主程序源码不方便重新编译的情况,则可以选择使用LeakDiag。LeakDiag是微软的一款内存泄漏检测工具,鉴于已经有大牛写了比较详尽的使用说明,我就不再赘述,直接引用大牛的博客地址:
http://www.cppblog.com/sandy/archive/2008/08/18/59260.html
LeakDiag下载地址:
ftp://ftp.microsoft.com/PSS/Tools/Developer%20Support%20Tools/LeakDiag/
工具:
1. IBM Rational PurifyPlus是一套完整的运行时分析工具,旨在提高应用程序的可靠性和性能。PurifyPlus将内存错误和泄漏检测、应用程序性能描述、代码覆盖分析等功能组合在一个单一、完整的工具包中。
网站:
http://www-128.ibm.com/developerworks/rational/products/purifyplus
从这里可以得到 IBM Rational 的试用版(DVD),
http://www-128.ibm.com/developerworks/cn/offers/sek/index.html
2. BoundsChecker
BoundsChecker是一个C++运行时错误检测和调试工具。它通过在VisualStudio内自动化调试过程加速开发并且缩短上市的周期。BoundsChecker提供清楚,详细的程序错误分析,许多是对C++独有的并且在
static,stack和heap内存中检测和诊断错误,以及发现内存和资源的泄漏。
3. http://www.parasoft.com/
4. http://www.glowcode.com/
但是我在win7下安装LeakDiag 老是报 Error 1722, 很奇怪, 目前还没有解决。。。
Vld 不能显示调用堆栈内容,网上说程序路径不能有中文,但是我的路径都是英文的也,是不是我的vs2005是中文的,是不是这个原因呢。。。
引用
Visual Leak Detector Version 1.0 installed (single-threaded static).
WARNING: Visual Leak Detector detected memory leaks!
---------- Block 125 at 0x004579E0: 100 bytes ----------
Call Stack:
0x00190000 (File and line number not available): (Function name unavailable)
0x00186000 (File and line number not available): (Function name unavailable)
Data:
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD ........ ........
---------- Block 124 at 0x004579A0: 1 bytes ----------
Call Stack:
Data:
CD ........ ........
WARNING: Visual Leak Detector detected memory leaks!
---------- Block 125 at 0x004579E0: 100 bytes ----------
Call Stack:
0x00190000 (File and line number not available): (Function name unavailable)
0x00186000 (File and line number not available): (Function name unavailable)
Data:
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD ........ ........
---------- Block 124 at 0x004579A0: 1 bytes ----------
Call Stack:
Data:
CD ........ ........
发表评论
-
curl
2015-03-11 17:18 331-H: 添加消息头, 如 -H "Host: www ... -
在线json转化工具
2013-05-14 14:39 0http://www.bejson.com/go.php?u= ... -
visual stdio 获取工具的方式
2013-04-02 15:34 0http://visualstudiogallery.msdn ... -
vim 操作笔记
2013-02-28 16:34 678v/"user_id" : NumberL ... -
RamDisk,内存虚拟硬盘
2012-11-07 16:16 1166转自:http://www.x-berry.com ... -
windows 下host 修改
2012-07-18 08:54 0c:\windwos\System32\drivers\etc ... -
快速清除Windows系统的垃圾
2012-07-15 15:12 0电脑在使用一段时间之后速度明显下降,很有可能是由于系统中的 ... -
objdump
2012-04-21 14:20 0http://sourceware.org/binutils/ ... -
VS2010快捷键及设置
2012-03-09 15:19 917VS2010快捷键设置 1.进入 ... -
vs2010 无法新建工程解决方法
2012-01-30 16:26 1197利用vs2010安装程序修复下就可以解决。 http://s ... -
pc-lint, visual lint, cpp-check
2011-10-21 19:15 2267转: http://www.cnblogs.com/highm ... -
磁盘加密工具,创建虚拟硬盘工具 TrueCrypt
2011-10-09 17:00 732非常强大的一个开源工具: 可以用于磁盘加密,创建虚拟硬盘 ... -
win7/windows 7 iss 安装图解
2011-09-01 11:29 706安装图解如下所示链接: 转:http://www.360 ... -
SCons -- make 的 替代(使用 SCons 轻松建造程序)
2011-08-25 14:08 1715简介: 在软件项目开发过程中,make 工具通常被用来建造程序 ...
相关推荐
windows下c++内存泄露检测工具使用方windows下c++内存泄露检测工具使用方
JS内存泄漏检测工具:IEJSLeaksDetector
移植了LeakTracer库到安卓平台,可以直接使用,带有例子
内存泄露检测工具boundschecker11
一款很好用 的内存泄漏检测工具,对初学者是个很好的学习机会
arm环境内存泄漏检测工具valgrind,用于检测arm环境下的内存泄漏
Lua内存泄露检测工具LuaMonitor下载.rar 对于Lua的性能检测提供良好的视图分析 可以获取当前内存图,方便对应项目的内存管理 可以获取热点函数相关信息
工具为评估试用版; 可以分析.net平台下编写的各类软件; 可以分析扩管类和非托管类代码;
内存泄漏 Web 的内存泄漏检测工具 更多信息请查看 www.iubang.com
一个非常好用的C++内存泄漏检测工具以及使用例子,可以方便地检测出开发的程序中内存泄漏情况,程序员必备工具之一。
推荐4款linux下的检测c语言编写的程序的内存泄漏工具 C语言和其他语言相比最大的特色就是能够操作内存 但是最常犯的错误也是内存泄漏(管杀不管埋) 所以我们需要用一些工具来帮助我们检测是否...奉上几款内存检测工具
LeakDiag和LDGrapher,windows内存泄漏排查工具,用于进行一些泄漏位置的查找以及可视化展示。
内存泄露检测工具--VisualLeakDetector。在软件调试尤其是底层开发时候用得很多的。
js内存泄漏检测工具;内存泄漏检测工具IE Javascript leaks detector
两个超棒的内存泄露检测工具,老外写的..
VLD(Visual Leak Detector)是一款用于Visual C++的免费的内存泄露检测工具。相比较其它的内存泄露检测工具.
VC内存泄露检测工具 Visual Leak Detector 介绍
开源的免费的内存泄漏检测工具,可用于VS2012、VS2010、VS2008、VS2005