随笔-调试-valgrind进行内存越界检查

valgrind进行内存越界检查

valgrind --log-file='valgrind_report.log' --time-stamp=yes –track-origins=yes --tool=memcheck --leak-check=full --show-leak-kinds=all ./exec
–track-origins=yes: 是否显示未定义的变量,在堆、栈中被定义没有被initialised的变量都被定义成origins。默认是关闭这个option的。
–show-leak-kinds=all : 这里可以支持的选项有[definite|possible],一般只需要关注definite(绝对),possible是可能会存在。
–leak-check=full : 当服务器退出时是否收集输出内存泄漏,选项有[no|summary|full]这个地方我们将其设置成全输出,默认将会使用summary方式

参考:http://valgrind.org/docs/manual/manual.html

posted @ 2024-05-07 21:49  LiYanbin  阅读(59)  评论(0编辑  收藏  举报