内存检测工具valgrind的安装和简单使用
2024-08-24 01:02:25
1. 安装
tar -jxvf valgrind-3.13..tar.bz2 cd valgrind-3.13. sudo ./configure sudo make sudo make install
2. 简单使用
#include <stdio.h>
#include <stdlib.h> void f()
{
int *x = malloc( * sizeof(int));
x[] = ;
} int main()
{
f(); return ;
}
gcc -g val.c -o main.out
valgrind --tool=memcheck --leak-check=yes --show-reachable=yes ./main.out
--leak-check=yes --show-reachable=yes ./main.out
==== Memcheck, a memory error detector
==== Copyright (C) -, and GNU GPL'd, by Julian Seward et al.
==== Using Valgrind-3.13. and LibVEX; rerun with -h for copyright info
==== Command: ./main.out
====
==== Invalid write of size
==== at 0x108668: f (val.c:)
==== by 0x10867E: main (val.c:)
==== Address 0x5857068 is bytes after a block of size alloc'd
==== at 0x4C2FB6B: malloc (vg_replace_malloc.c:)
==== by 0x10865B: f (val.c:)
==== by 0x10867E: main (val.c:)
====
====
==== HEAP SUMMARY:
==== in use at exit: bytes in blocks
==== total heap usage: allocs, frees, bytes allocated
====
==== bytes in blocks are definitely lost in loss record of
==== at 0x4C2FB6B: malloc (vg_replace_malloc.c:)
==== by 0x10865B: f (val.c:)
==== by 0x10867E: main (val.c:)
====
==== LEAK SUMMARY:
==== definitely lost: bytes in blocks
==== indirectly lost: bytes in blocks
==== possibly lost: bytes in blocks
==== still reachable: bytes in blocks
==== suppressed: bytes in blocks
====
==== For counts of detected and suppressed errors, rerun with: -v
==== ERROR SUMMARY: errors from contexts (suppressed: from )
3. 进阶
待续
最新文章
- angular源码分析:$compile服务——指令的编写
- 【Linux_Fedora_应用系列】_2_如何安装视频播放器和视频文件解码
- linux中send函数MSG_NOSIGNAL异常消息
- [转]在EntityFramework6中执行SQL语句
- [问题2015S08] 复旦高等代数 II(14级)每周一题(第九教学周)
- DKNightVersion 的实现 --- 如何为 iOS 应用添加夜间模式
- IP分片浅析
- linux安装软件命令
- Linux系统编程(15)——shell脚本语法
- CATALINA_BASE与CATALINA_HOME的区别(转)
- C#保留小数位数的方法
- bat复制文件夹下所有文件到另一个目录
- lab-kvm
- Ubuntu 离线安装 docker
- BZOJ2242[SDOI2011]计算器——exgcd+BSGS
- Background Media Recovery terminated with ORA-1274 after adding a Datafile (Doc ID 739618.1)
- Centos 6.4 安装dnsmasq
- 在屏幕拖拽3D物体移动
- extends 扩展选项
- java环境配置针对win10(电脑重装必备) 最后一步很重要
热门文章
- No converter found capable of converting from type [java.lang.String] to type [java.util.Map<;java.lang.String, java.lang.String>;]
- 《BUG创造队》作业8:软件测试与Alpha冲刺(第一天)
- python_并发编程——事件
- 评估预测函数(3)---Model selection(选择多项式的次数) and Train/validation/test sets
- Java - Oscache 缓存
- [React] Write a Custom State Hook in React
- C# winform Panel 添加 滚动条
- Hadoop上 Hive 操作
- 2019.11.29 Mysql的数据操作
- Python中多层List展平为一层