安装
valgrind官网下载链接
安装过程:
tar -xf valgrind-3.22.0.tar.bz2
cd valgrind-3.22.0/
./configure
make
make install
使用
基本工具
- Memcheck,检测内存错误使用问题
- Callgrind,检查程序函数调用过程中出现的问题
- Cachegrind,检查程序缓存使用出现的问题
- Helgrind,检查多线程程序出现的竞争问题
- Massif,检查程序中堆栈使用中出现的问题
- Extension,利用core提供的功能,自己编写特定的内存调试工具
检测内存错误
valgrind --leak-check=yes ./[程序名]