公众号:offer多多
V1
2022/02/21阅读:39主题:橙心
Valgrind的Massif工具
Valgrind的Massif工具进行C++内存使用分析
原理看不懂直接动手测试
官方提供例子
https://valgrind.org/docs/manual/ms-manual.html
yum install valgrind
gcc -o test test.c
valgrind --tool=massif ./test
valgrind --tool=massif --time-unit=B ./test
valgrind -v --tool=massif --time-unit=B --detailed-freq=1 ./test
ms_print massif.out.5425
小白提问:内容看不懂,不知道背后代码 含义 和代码有什么关系?
坐标图详解
坐标图中
":"表示普通快照、
"@"表示详细快照、
"#"表示峰值快照;
坐标图左下角的"Number of snapshots: 25"是快照总数
"Detailed snapshots: [9, 14 (peak), 24]" 是详细快照列表,peak表示峰值快照。
-
使用ms_print显示可视化效果不好,可以通过massif-visualizer对结果进行可视化显示。
-
Tool for visualizing memory usage recorded by Valgrind Massif https://snapcraft.io/install/massif-visualizer/centos massif-visualizer ./massif.out
githu 例子
https://github.com/fengbingchun/Messy_Test
./build.sh valgrind --tool=massif ./build/CppBaseTest
redis
valgrind --tool=massif /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
# valgrind --tool=massif /usr/local/memcached/bin/memcached -d -m 64 -uroot -l 0.0.0.0 -p 11211 -c 1024
# valgrind --tool=massif /usr/redis-2.8.1/src/redis-server
ref
-
https://rebootcat.com/2020/06/16/valgrind_massif_memory_analysing/
https://blog.csdn.net/breaksoftware/article/details/81202015 https://www.i4k.xyz/article/liweigao01/81292184
golang heap profile
https://www.jianshu.com/p/162f44022eb7
作者介绍
公众号:offer多多
V1