首页 技术 正文
技术 2022年11月15日
0 收藏 568 点赞 2,609 浏览 1887 个字

Valgrind 是个开源的工具,功能很多。例如检查内存泄漏工具—memcheck。

安装:

1)官网下载:http://www.valgrind.org/downloads/ , 下载tar.bz2之后,可以传送到linux。更方便的是用linux的wget命令直接下载: wget ftp://sourceware.org/pub/valgrind/valgrind-3.13.0.tar.bz2,wget后面的下载地址,鼠标右击网站上的文件名,赋值链接即可。

2)tar -jxvf valgrind-3.13.0.tar.bz2

3)参照其README文件,按照指示安装:

To install from a tar.bz2 distribution:

  a. Run ./configure, with some options if you wish.  The only interesting one is the usual –prefix=/where/you/want/it/installed.

    我令prefix=/usr/local/valgrind3.13.0,这样所有的安装文件都在这个目录,卸载时只要删除这个文件即可。

  b. Run “make”.

  c. Run “make install”, possibly as root if the destination permissions require that.

  d. See if it works.  Try “valgrind ls -l”.  Either this works, or it bombs out with some complaint.  In that case, please let us know

     (see www.valgrind.org).

安装完成后,在terminal能自动识别valgrind指令,应该是在安装过程中自动加入了环境变量吧,执行make install时要求我以root身份啦。

Important!  Do not move the valgrind installation into a place different from that specified by –prefix at build time.  This will

cause things to break in subtle ways, mostly when Valgrind handles fork/exec calls.

用法:

valgrind [options] prog-and-args

[options]: 常用选项,适用于所有Valgrind工具

 -tool=<name> 最常用的选项。运行 valgrind中名为toolname的工具。默认memcheck。

memcheck ——> 这是valgrind应用最广泛的工具,一个重量级的内存检查器,能够发现开发中绝大多数内存错误使用情况,  比如:使用未初始化的内存,使用已经释放了的内存,内存访问越界等。

callgrind ——> 它主要用来检查程序中函数调用过程中出现的问题。

cachegrind ——> 它主要用来检查程序中缓存使用出现的问题。

helgrind ——> 它主要用来检查多线程程序中出现的竞争问题。

massif ——> 它主要用来检查程序中堆栈使用中出现的问题。

extension ——> 可以利用core提供的功能,自己编写特定的内存调试工具

-h –help 显示帮助信息。

    -version 显示valgrind内核的版本,每个工具都有各自的版本。

    -q –quiet 安静地运行,只打印错误信息。

    -v –verbose 更详细的信息, 增加错误数统计。

    -trace-children=no|yes 跟踪子线程? [no]

    -track-fds=no|yes 跟踪打开的文件描述?[no]

    -time-stamp=no|yes 增加时间戳到LOG信息? [no]

    -log-fd=<number> 输出LOG到描述符文件 [2=stderr]

    -log-file=<file> 将输出的信息写入到filename.PID的文件里,PID是运行程序的进行ID

    -log-file-exactly=<file> 输出LOG信息到 file

    -log-file-qualifier=<VAR> 取得环境变量的值来做为输出信息的文件名。 [none]

    -log-socket=ipaddr:port 输出LOG到socket ,ipaddr:port

REF:

https://www.cnblogs.com/AndyStudy/p/6409287.html

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,154
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,622
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,465
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,239
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,874
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,042