news 2026/11/6 1:29:38

【RHCA+】valgrind命令(检测内存泄漏)

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
【RHCA+】valgrind命令(检测内存泄漏)

“ 目录:RHCA+ -> 12 系统监控 -> 33 valgrind命令(检测内存泄漏) ”

内存调试和性能分析工具,常用于检测内存泄漏、非法内存访问、使用未初始化变量等;语法格式:valgrind [参数] 被检测命令

此命令会降低被检测命令的运行速度10-50倍,所以只用于调试

参数

作用

--tool

指定分析工具

memcheck:跟踪非法内存访问

cachegrind:分析缓存、性能

helgrind:检测多线程竞争、锁等问题

--log-file

将输出重定向到文件

--v

查看详细信息

--vv

查看更详细的信息

--track-fds=yes

跟踪文件描述符泄漏

--suppressions=文件名

忽略指定规则文件中定义的错误

--leak-check=full

查看详细的内存泄漏信息,包括未释放的内存位置

--track-origins=yes

查看未初始化变量的来源,比如具体代码行

回显结果

definitely lost:内存泄漏

possibly lost:可能泄漏,例:指针未置空

still reachable:程序结束时仍可达的内存,通常是全局变量

一、安装

[root@wuzuniao ~]# yum -y install valgrind #安装调试软件

二、使用

[root@wuzuniao ~]# valgrind --leak-check=full ls #检查是否有内存泄露

==3364== Memcheck, a memory error detector

==3364== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.

==3364== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info

==3364== Command: ls

==3364==

anaconda-ks.cfg a.txt cpuset Desktop Documents Downloads initial-setup-ks.cfg Music Pictures Public Templates Videos

==3364==

==3364== HEAP SUMMARY:

==3364== in use at exit: 22,693 bytes in 18 blocks

==3364== total heap usage: 52 allocs, 34 frees, 59,240 bytes allocated

==3364==

==3364== LEAK SUMMARY:

==3364== definitely lost: 0 bytes in 0 blocks

==3364== indirectly lost: 0 bytes in 0 blocks

==3364== possibly lost: 0 bytes in 0 blocks

==3364== still reachable: 22,693 bytes in 18 blocks

==3364== suppressed: 0 bytes in 0 blocks

==3364== Reachable blocks (those to which a pointer was found) are not shown.

==3364== To see them, rerun with: --leak-check=full --show-leak-kinds=all

==3364==

==3364== For counts of detected and suppressed errors, rerun with: -v

==3364== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 3 from 3)

[root@wuzuniao ~]#

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/11/6 1:27:38

[tip] ssh远程连接主机免密码登录

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

作者头像 李华
网站建设 2026/11/6 1:24:30

xLua 性能优化实战:4 步把 Lua 卡顿压回 60fps

xLua 性能优化实战:4 步把 Lua 卡顿压回 60fps 【免费下载链接】xLua xLua is a lua programming solution for C# ( Unity, .Net, Mono) , it supports android, ios, windows, linux, osx, etc. 项目地址: https://gitcode.com/gh_mirrors/xl/xLua xLua 是…

作者头像 李华
网站建设 2026/11/6 1:23:24

Weylus:3 步把平板变成电脑绘图板,压感多触全都有

Weylus:3 步把平板变成电脑绘图板,压感多触全都有 【免费下载链接】Weylus Use your tablet as graphic tablet/touch screen on your computer. 项目地址: https://gitcode.com/gh_mirrors/we/Weylus 家里有闲置的平板,却只是吃灰&am…

作者头像 李华
网站建设 2026/11/6 1:22:49

十分钟读懂智能电表 DLMS/COSEM 通信:Wireshark 抓包与排障实操

十分钟读懂智能电表 DLMS/COSEM 通信:Wireshark 抓包与排障实操 【免费下载链接】wireshark Read-only mirror of Wiresharks Git repository at https://gitlab.com/wireshark/wireshark. Youre welcome to submit pull requests there. 项目地址: https://gitco…

作者头像 李华
网站建设 2026/11/6 1:17:46

Pillow识别极验消消乐验证码

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

作者头像 李华
网站建设 2026/11/6 1:17:06

07:输出浮点数

/*** 题目名称&#xff1a;输出浮点数 <p>* 题目来源&#xff1a;http://noi.openjudge.cn/ch0101/07/ <p>* 程序功能&#xff1a;按题目要求以不同的格式化输出一个双精度浮点数** author 潘磊&#xff0c;just_panleijust.edu.cn* version 1.0*/// 本题Java无法A…

作者头像 李华