valgrind

Valgrind 内存与性能分析

补充说明

valgrind 是动态分析工具集,memcheck 检测内存错误/泄漏,callgrind 做性能剖析,helgrind 检查线程问题。它通过模拟执行,速度较慢。

常用示例

valgrind --leak-check=full ./app
valgrind --leak-check=full --show-leak-kinds=all ./app
valgrind --track-origins=yes ./app
valgrind --tool=callgrind ./app
callgrind_annotate callgrind.out.<pid>
valgrind --tool=helgrind ./app
valgrind --log-file=vg.log ./app
valgrind --suppressions=app.supp ./app

常用工具

工具 用途
memcheck 内存越界/未初始化/泄漏
callgrind 指令级性能剖析
cachegrind 缓存命中分析
helgrind 线程竞争
drd 线程/锁分析

易错点与排错

相关命令