我应该抑制吗?如果是这样如何从Makefile中抑制

时间:2014-10-14 05:07:57

标签: c++ makefile valgrind suppression

我有几个运行的测试,最后我运行Valgrind来验证我的库内存使用情况。 Valgrind一直抱怨:

==27022== HEAP SUMMARY:
==27022==     in use at exit: 6,139 bytes in 3 blocks
==27022==   total heap usage: 609 allocs, 606 frees, 19,877,073 bytes allocated
==27022== 
==27022== 32 bytes in 1 blocks are still reachable in loss record 1 of 3
==27022==    at 0x4A08121: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==27022==    by 0x3A1A60168F: _dlerror_run (in /usr/lib64/libdl-2.17.so)
==27022==    by 0x3A1A601197: dlsym (in /usr/lib64/libdl-2.17.so)
==27022==    by 0x3A9D8A796D: ??? (in /usr/lib64/nvidia/libGL.so.331.67)
==27022==    by 0x3A9DAE965F: ??? (in /usr/lib64/nvidia/libGL.so.331.67)
==27022==    by 0x3A9DB1CB1F: ???
==27022==    by 0x3A9D8CD36A: ??? (in /usr/lib64/nvidia/libGL.so.331.67)
==27022== 
==27022== 83 bytes in 1 blocks are still reachable in loss record 2 of 3
==27022==    at 0x4A06409: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==27022==    by 0x3A1A2863F9: strdup (in /usr/lib64/libc-2.17.so)
==27022==    by 0x3A9D8A964E: ??? (in /usr/lib64/nvidia/libGL.so.331.67)
==27022==    by 0x6578652F32322F: ???
==27022== 
==27022== 6,024 bytes in 1 blocks are definitely lost in loss record 3 of 3
==27022==    at 0x4A08121: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==27022==    by 0x3A9D8C032E: ??? (in /usr/lib64/nvidia/libGL.so.331.67)
==27022== 
==27022== LEAK SUMMARY:
==27022==    definitely lost: 6,024 bytes in 1 blocks
==27022==    indirectly lost: 0 bytes in 0 blocks
==27022==      possibly lost: 0 bytes in 0 blocks
==27022==    still reachable: 115 bytes in 2 blocks
==27022==         suppressed: 0 bytes in 0 blocks

这些似乎与我的图书馆无关。我应该关注这些警告吗? 或者我应该尝试抑制这些泄漏?如果我应该从Makefile中压制出最干净的方法呢?

1 个答案:

答案 0 :(得分:1)

很难说你是否应该压制它们,但如果你确定你的图书馆是干净的,你可以生成suppression file

然后你可以用'#34; - 抑制"来调用Valgrind。旗。如果抑制文件的名称是suppfile:

> valgrind --suppressions=suppfile ./program

如果从Makefile执行valgrind,请将suppressions标志添加到valgrind命令。您还可以创建一个default options file" .valgrindrc",它与Makefile放在同一目录中。在此文件中,输入您想要的任何参数。