ROS中用到第三方库,在编译第三方库的时候,加上 -g 选项,以供调用该库时调试。
在编译ROS包的时候,使用如下命令编译:
catkin_make -DCMAKE_BUILD_TYPE=Debug
1、打开roscore
$ roscore
2、用valgrind打开程序
$ valgrind --tool=memcheck --leak-check=yes --log-file=valgrind.log ./devel/lib/package_foo/executable_bar
you will not get useful memory stats. I believe this is due to rosrun spawning your node in a separate process. To get around this, you can call your executable directly:
$ valgrind --tool=memcheck --leak-check=yes --log-file=valgrind.log rosrun package_foo executable_bar,
Alternatively, you could write your own launchfile with Valgrind in the launch-prefix.