-
官网下载源码
-
cd valgrind-3.18.1
-
./autogen.sh
-
./configure --prefix=安装
-
make -j4
-
make install
运行时需要设置
-
export VALGRIND_LIB=安装目录/libexec/valgrind
-
如果报错,需要安装apt-get install libc6-dbg
-
使用命令行运行
valgrind --tool=memcheck --show-mismatched-frees=yes --track-origins=yes --leak-check=full --show-leak-kinds=all --log-file=valgrind.log --error-limit=no ./main