内存泄漏检查工具
2016-04-30 19:21
288 查看
MEMWATCH
下载地址: memwatchMEMWATCH 支持ANSIC,它提供结果日志纪录,能检测双重释放(double-free)、错误释放(erroneous free)、没有释放的内存(unfreedmemory)、溢出和下溢等等。
#include <stdlib.h> #include <stdio.h> #include "memwatch.h" int main(void) { char *ptr1; char *ptr2; ptr1 = malloc(512); ptr2 = malloc(512); ptr2 = ptr1; free(ptr2); free(ptr1); } 使用的时候只要添加头文件"memwatch.h",然后使用gcc编译的时候添加-DMEMWATCH -DMW_STDIO gcc -DMEMWATCH -DMW_STDIO test1.c memwatch.c -o test1
当运行程序./test1的时候会生成一个关于泄漏的内存的报告memwatch.log。
MEMWATCH 2.67 Copyright (C) 1992-1999 Johan Lindh ... double-free: <4> test1.c(15), 0x80517b4 was freed from test1.c(14) ... unfreed: <2> test1.c(11), 512 bytes at 0x80519e4 {FE FE FE FE FE FE FE FE FE FE FE FE ..............} Memory usage statistics (global): N)umber of allocations made: 2 L)argest memory usage : 1024 T)otal of all alloc() calls: 1024 U)nfreed bytes totals : 512
YAMD
参考文章
Linux内核调试方法总结相关文章推荐
- 第一章 目录
- 自定义Cell的方法
- MySQL常用命令
- python 的.join()方法
- 一致性哈希算法详解
- Codeforces #349 div1 A. Reberland Linguistics 模拟 递推
- 集合 判断是否为同一元素 总结
- 如何从ToughRADIUS V1版本迁移数据到 ToughRADIUS V2版本
- LIGHTOJ1048_Conquering Keokradong
- requires the IDE to be running with java 1.8 or later 解决方法
- 第九周学习进度条
- js函数
- mysql优化,不用怕面试题了
- 第十章 springboot + logback
- 225. Implement Stack using Queues
- 让IE7支持display: inline-block;
- Java集合类操作优化经验总结
- The operation couldn’t be completed. (FBSOpenApplicationErrorDomain error 3.)
- 完全使用 SFTP 替代 FTP :SFTP+OpenSSH+ChrootDirectory 设置详解
- PandaRSS 自助服务系统安装配置