C++ 检测内存泄露工具 -- Windows平台
来源:互联网 发布:php前端和后端 编辑:程序博客网 时间:2024/06/06 19:31
C++ 检测内存泄露工具 -- Windows平台
平台:Windows7 64bit,编译器G++(mingw)
工具:Dr Memory,项目主页:https://code.google.com/p/drmemory/ (可能要FQ,可能会很慢,所以,可以直接按照下面官方主页给出的链接下载,我也放了一份Windows版的在百度网盘,http://pan.baidu.com/s/1qWv2tZm,这个应该肯定可以下载)
The latest versions can be directly accessed here:
- Dr. Memory installer for Windows (DrMemory-Windows-1.7.0-5.exe)
- Dr. Memory zip file for portable/local installation on Windows (DrMemory-Windows-1.7.0-5.zip)
- Dr. Memory for Linux (DrMemory-Linux-1.7.0-5.tar.gz)
- Dr. Memory for Mac (DrMemory-MacOS-1.7.0-5.tar.gz)
- Dr. Memory source code (DrMemory-1.7.0-5-Source.tar.gz)
2014-08-30日摘录于https://code.google.com/p/drmemory/wiki/Downloads?tm=2
用法类似于Linux下的Valgrind,非常简单
测试代码:
#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停止工作")
执行drmemory test.exe
这样应该就会生成一个报告,可以看到Error #1: LEAK 100 direct bytes 0x00c80ea8-0x00c80f0c + 0 indirect bytes
关于微软的App Verifier,http://msdn.microsoft.com/en-us/library/windows/hardware/ff551063(v=vs.85).aspx, 按照说明可以下载其中的debugging tool,安装成功后,搞了半天也没学会怎么用……
我是用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/
源文:http://www.cnblogs.com/fstang/p/3946294.html
- C++ 检测内存泄露工具 -- Windows平台
- 内存泄露 检测 工具
- C 检测内存泄露
- linux平台检测c/c++内存泄露方法
- 检测内存泄露的工具
- windows下内存泄露检测
- c/c++ 内存泄露检测
- C/C++ 内存泄露检测
- C++ 检测内存泄露
- ★【C/C++】概念:内存泄露与内存泄露检测
- 基于日志的内存泄露检测方法(跨平台,支持C/C++)
- c内存泄露工具-memleak
- 大家用什么工具检测内存泄露
- 检测内存泄露的工具:debugnew
- 检测内存泄露的工具:debugnew
- 检测内存泄露的工具:debugnew
- 内存泄露检测—VLD工具
- 内存泄露检测—VLD工具
- linux下递归修改子目录内的文件名
- verilog中,像2`B01 、 4`H0 、 16`H4012 之类的是什么意思啊
- 2016美国数学建模MCM c题 翻译:Goodgrant基金会的挑战
- 如何读取assets目录下存放的原生资源文件
- Go语言圣经(中文版)
- C++ 检测内存泄露工具 -- Windows平台
- JSONKit报错
- OpenCV3.1+numpy1.10.4+ubuntu14.04 x86_64:
- linux中的libz.so.1库文件丢失解决办法
- 项目总结二:龙图OA项目总结
- C point and array practice
- 从头认识Spring-1.2 什么是AOP?为什么需要面向切面编程?
- Docker镜像和容器系列(二)- 操作详解
- IOS CALayer 详解