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. 进阶

待续

最新文章

  1. angular源码分析:$compile服务——指令的编写
  2. 【Linux_Fedora_应用系列】_2_如何安装视频播放器和视频文件解码
  3. linux中send函数MSG_NOSIGNAL异常消息
  4. [转]在EntityFramework6中执行SQL语句
  5. [问题2015S08] 复旦高等代数 II(14级)每周一题(第九教学周)
  6. DKNightVersion 的实现 --- 如何为 iOS 应用添加夜间模式
  7. IP分片浅析
  8. linux安装软件命令
  9. Linux系统编程(15)——shell脚本语法
  10. CATALINA_BASE与CATALINA_HOME的区别(转)
  11. C#保留小数位数的方法
  12. bat复制文件夹下所有文件到另一个目录
  13. lab-kvm
  14. Ubuntu 离线安装 docker
  15. BZOJ2242[SDOI2011]计算器——exgcd+BSGS
  16. Background Media Recovery terminated with ORA-1274 after adding a Datafile (Doc ID 739618.1)
  17. Centos 6.4 安装dnsmasq
  18. 在屏幕拖拽3D物体移动
  19. extends 扩展选项
  20. java环境配置针对win10(电脑重装必备) 最后一步很重要

热门文章

  1. No converter found capable of converting from type [java.lang.String] to type [java.util.Map&lt;java.lang.String, java.lang.String&gt;]
  2. 《BUG创造队》作业8:软件测试与Alpha冲刺(第一天)
  3. python_并发编程——事件
  4. 评估预测函数(3)---Model selection(选择多项式的次数) and Train/validation/test sets
  5. Java - Oscache 缓存
  6. [React] Write a Custom State Hook in React
  7. C# winform Panel 添加 滚动条
  8. Hadoop上 Hive 操作
  9. 2019.11.29 Mysql的数据操作
  10. Python中多层List展平为一层