平台:Windows7 64bit,编译器G++(mingw)windows
工具:Dr Memory,项目主页:https://code.google.com/p/drmemory/ (可能要FQ,可能会很慢,因此,能够直接按照下面官方主页给出的连接下载,我也放了一份Windows版的在百度网盘,http://pan.baidu.com/s/1qWv2tZm,这个应该确定能够下载)wordpress
The latest versions can be directly accessed here:工具
2014-08-30日摘录于https://code.google.com/p/drmemory/wiki/Downloads?tm=2测试
用法相似于Linux下的Valgrind,很是简单google
测试代码:spa
#include <cstdio> int main(int argc, const char *argv[]) { char *s; s = new char[100]; return 0; }
用g++编译,g++ test.cpp -o test (貌似必须有-o选项指定输出文件名,用g++ test.cpp会生成a.exe,可是用drmemory会致使显示"a.exe中止工做")debug
执行drmemory test.exe调试
这样应该就会生成一个报告,能够看到Error #1: LEAK 100 direct bytes 0x00c80ea8-0x00c80f0c + 0 indirect bytescode
关于微软的App Verifier,http://msdn.microsoft.com/en-us/library/windows/hardware/ff551063(v=vs.85).aspx, 按照说明能够下载其中的debugging tool,安装成功后,搞了半天也没学会怎么用……blog
我是用mingw的工具编译和调试,g++ file.cpp -o file,生成exe,打开App Verifier,添加这个exe,执行gdb file.exe,run的时候确实看到说App Verifier enable了,可是不管是运行过程当中仍是运行以后都看不到log。极可能是只能和windbg工具一块儿使用,可能还要用微软的编译器。搜索 “App Verifier 内存泄露”能够获得不少相关文章,好比这篇文章:http://www.zzfjh.com/?p=105
参考:
https://code.google.com/p/drmemory/
http://latedev.wordpress.com/2012/05/19/valgrind-for-windows/