1. 官网下载源码
2. cd valgrind-3.18.1
3. ./autogen.sh
4. ./configure --prefix=安装
5. make -j4
6. make install
运行时需要设置
1. export VALGRIND_LIB=安装目录/libexec/valgrind
2. 如果报错,需要安装apt-get install libc6-dbg
3. 使用命令行运行
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