使用valgrind检查内存泄漏

 

使用valgrind检查内存泄漏

安装1.2

$ wget https://sourceware.org/pub/valgrind/valgrind-3.22.0.tar.bz2
$ tar -xvf valgrind-3.22.0.tar.bz2
$ cd valgrind-3.22.0/
$ ./configure
$ make
$ sudo make install

使用1.3.4

注意C++程序在静态编译时要使用 -g 加入调试信息。

# 对于如下一个程序
$ ros2 launch fisheye_perception_node front8m_perception_foxg.launch.py

# 加上前缀即可
$ valgrind --tool=memcheck --leak-check=full ros2 launch fisheye_perception_node front8m_perception_foxg.launch.py

参考资料

  1. How to install valgrind properly?
  2. valgrind-current release
  3. 使用 Valgrind 检测 C++ 内存泄漏
  4. valgrind的使用