我正在尝试从正在处理的C ++应用程序中查找内存泄漏。我用以下命令执行valgrind:
valgrind --leak-check=full --show-reachable=yes ./myApp <parameters>
Valgrind给我以下输出:
==32375==
==32375== HEAP SUMMARY:
==32375== in use at exit: 528 bytes in 11 blocks
==32375== total heap usage: 19,139 allocs, 19,128 frees, 429,638,284 bytes allocated
==32375==
==32375== 48 bytes in 1 blocks are still reachable in loss record 1 of 11
==32375== at 0x4C2A1E3: operator new(unsigned long) (vg_replace_malloc.c:334)
==32375== by 0xAC2AAE8: _GLOBAL__sub_I_binary_iarchive.cpp (in boostLocation/lib/libboost_serialization.so.1.67.0)
==32375== by 0x400F8F2: _dl_init (in /usr/lib64/ld-2.17.so)
==32375== by 0x4001159: ??? (in /usr/lib64/ld-2.17.so)
==32375== by 0x6: ???
==32375== by 0x1FFEFFFAE6: ???
==32375== by 0x1FFEFFFB38: ???
==32375== by 0x1FFEFFFB3B: ???
==32375== by 0x1FFEFFFB54: ???
==32375== by 0x1FFEFFFB57: ???
==32375== by 0x1FFEFFFB59: ???
==32375== by 0x1FFEFFFB5C: ???
==32375==
==32375== 48 bytes in 1 blocks are still reachable in loss record 2 of 11
==32375== at 0x4C2A1E3: operator new(unsigned long) (vg_replace_malloc.c:334)
==32375== by 0xAC2AB68: _GLOBAL__sub_I_binary_oarchive.cpp (in boostLocation/lib/libboost_serialization.so.1.67.0)
==32375== by 0x400F8F2: _dl_init (in /usr/lib64/ld-2.17.so)
==32375== by 0x4001159: ??? (in /usr/lib64/ld-2.17.so)
==32375== by 0x6: ???
==32375== by 0x1FFEFFFAE6: ???
==32375== by 0x1FFEFFFB38: ???
==32375== by 0x1FFEFFFB3B: ???
==32375== by 0x1FFEFFFB54: ???
==32375== by 0x1FFEFFFB57: ???
==32375== by 0x1FFEFFFB59: ???
==32375== by 0x1FFEFFFB5C: ???
==32375==
==32375== 48 bytes in 1 blocks are still reachable in loss record 3 of 11
==32375== at 0x4C2A1E3: operator new(unsigned long) (vg_replace_malloc.c:334)
==32375== by 0xAC2ABE8: _GLOBAL__sub_I_extended_type_info.cpp (in boostLocation/lib/libboost_serialization.so.1.67.0)
==32375== by 0x400F8F2: _dl_init (in /usr/lib64/ld-2.17.so)
==32375== by 0x4001159: ??? (in /usr/lib64/ld-2.17.so)
==32375== by 0x6: ???
==32375== by 0x1FFEFFFAE6: ???
==32375== by 0x1FFEFFFB38: ???
==32375== by 0x1FFEFFFB3B: ???
==32375== by 0x1FFEFFFB54: ???
==32375== by 0x1FFEFFFB57: ???
==32375== by 0x1FFEFFFB59: ???
==32375== by 0x1FFEFFFB5C: ???
==32375==
==32375== 48 bytes in 1 blocks are still reachable in loss record 4 of 11
==32375== at 0x4C2A1E3: operator new(unsigned long) (vg_replace_malloc.c:334)
==32375== by 0xAC2AC68: _GLOBAL__sub_I_extended_type_info_typeid.cpp (in boostLocation/lib/libboost_serialization.so.1.67.0)
==32375== by 0x400F8F2: _dl_init (in /usr/lib64/ld-2.17.so)
==32375== by 0x4001159: ??? (in /usr/lib64/ld-2.17.so)
==32375== by 0x6: ???
==32375== by 0x1FFEFFFAE6: ???
==32375== by 0x1FFEFFFB38: ???
==32375== by 0x1FFEFFFB3B: ???
==32375== by 0x1FFEFFFB54: ???
==32375== by 0x1FFEFFFB57: ???
==32375== by 0x1FFEFFFB59: ???
==32375== by 0x1FFEFFFB5C: ???
==32375==
==32375== 48 bytes in 1 blocks are still reachable in loss record 5 of 11
==32375== at 0x4C2A1E3: operator new(unsigned long) (vg_replace_malloc.c:334)
==32375== by 0xAC2ACE8: _GLOBAL__sub_I_polymorphic_iarchive.cpp (in boostLocation/lib/libboost_serialization.so.1.67.0)
==32375== by 0x400F8F2: _dl_init (in /usr/lib64/ld-2.17.so)
==32375== by 0x4001159: ??? (in /usr/lib64/ld-2.17.so)
==32375== by 0x6: ???
==32375== by 0x1FFEFFFAE6: ???
==32375== by 0x1FFEFFFB38: ???
==32375== by 0x1FFEFFFB3B: ???
==32375== by 0x1FFEFFFB54: ???
==32375== by 0x1FFEFFFB57: ???
==32375== by 0x1FFEFFFB59: ???
==32375== by 0x1FFEFFFB5C: ???
==32375==
==32375== 48 bytes in 1 blocks are still reachable in loss record 6 of 11
==32375== at 0x4C2A1E3: operator new(unsigned long) (vg_replace_malloc.c:334)
==32375== by 0xAC2AD68: _GLOBAL__sub_I_polymorphic_oarchive.cpp (in boostLocation/lib/libboost_serialization.so.1.67.0)
==32375== by 0x400F8F2: _dl_init (in /usr/lib64/ld-2.17.so)
==32375== by 0x4001159: ??? (in /usr/lib64/ld-2.17.so)
==32375== by 0x6: ???
==32375== by 0x1FFEFFFAE6: ???
==32375== by 0x1FFEFFFB38: ???
==32375== by 0x1FFEFFFB3B: ???
==32375== by 0x1FFEFFFB54: ???
==32375== by 0x1FFEFFFB57: ???
==32375== by 0x1FFEFFFB59: ???
==32375== by 0x1FFEFFFB5C: ???
==32375==
==32375== 48 bytes in 1 blocks are still reachable in loss record 7 of 11
==32375== at 0x4C2A1E3: operator new(unsigned long) (vg_replace_malloc.c:334)
==32375== by 0xAC2ADE8: _GLOBAL__sub_I_text_iarchive.cpp (in boostLocation/lib/libboost_serialization.so.1.67.0)
==32375== by 0x400F8F2: _dl_init (in /usr/lib64/ld-2.17.so)
==32375== by 0x4001159: ??? (in /usr/lib64/ld-2.17.so)
==32375== by 0x6: ???
==32375== by 0x1FFEFFFAE6: ???
==32375== by 0x1FFEFFFB38: ???
==32375== by 0x1FFEFFFB3B: ???
==32375== by 0x1FFEFFFB54: ???
==32375== by 0x1FFEFFFB57: ???
==32375== by 0x1FFEFFFB59: ???
==32375== by 0x1FFEFFFB5C: ???
==32375==
==32375== 48 bytes in 1 blocks are still reachable in loss record 8 of 11
==32375== at 0x4C2A1E3: operator new(unsigned long) (vg_replace_malloc.c:334)
==32375== by 0xAC2AE68: _GLOBAL__sub_I_text_oarchive.cpp (in boostLocation/lib/libboost_serialization.so.1.67.0)
==32375== by 0x400F8F2: _dl_init (in /usr/lib64/ld-2.17.so)
==32375== by 0x4001159: ??? (in /usr/lib64/ld-2.17.so)
==32375== by 0x6: ???
==32375== by 0x1FFEFFFAE6: ???
==32375== by 0x1FFEFFFB38: ???
==32375== by 0x1FFEFFFB3B: ???
==32375== by 0x1FFEFFFB54: ???
==32375== by 0x1FFEFFFB57: ???
==32375== by 0x1FFEFFFB59: ???
==32375== by 0x1FFEFFFB5C: ???
==32375==
==32375== 48 bytes in 1 blocks are still reachable in loss record 9 of 11
==32375== at 0x4C2A1E3: operator new(unsigned long) (vg_replace_malloc.c:334)
==32375== by 0xAC2AEE8: _GLOBAL__sub_I_void_cast.cpp (in boostLocation/lib/libboost_serialization.so.1.67.0)
==32375== by 0x400F8F2: _dl_init (in /usr/lib64/ld-2.17.so)
==32375== by 0x4001159: ??? (in /usr/lib64/ld-2.17.so)
==32375== by 0x6: ???
==32375== by 0x1FFEFFFAE6: ???
==32375== by 0x1FFEFFFB38: ???
==32375== by 0x1FFEFFFB3B: ???
==32375== by 0x1FFEFFFB54: ???
==32375== by 0x1FFEFFFB57: ???
==32375== by 0x1FFEFFFB59: ???
==32375== by 0x1FFEFFFB5C: ???
==32375==
==32375== 48 bytes in 1 blocks are still reachable in loss record 10 of 11
==32375== at 0x4C2A1E3: operator new(unsigned long) (vg_replace_malloc.c:334)
==32375== by 0xAC2AF68: _GLOBAL__sub_I_xml_iarchive.cpp (in boostLocation/lib/libboost_serialization.so.1.67.0)
==32375== by 0x400F8F2: _dl_init (in /usr/lib64/ld-2.17.so)
==32375== by 0x4001159: ??? (in /usr/lib64/ld-2.17.so)
==32375== by 0x6: ???
==32375== by 0x1FFEFFFAE6: ???
==32375== by 0x1FFEFFFB38: ???
==32375== by 0x1FFEFFFB3B: ???
==32375== by 0x1FFEFFFB54: ???
==32375== by 0x1FFEFFFB57: ???
==32375== by 0x1FFEFFFB59: ???
==32375== by 0x1FFEFFFB5C: ???
==32375==
==32375== 48 bytes in 1 blocks are still reachable in loss record 11 of 11
==32375== at 0x4C2A1E3: operator new(unsigned long) (vg_replace_malloc.c:334)
==32375== by 0xAC2AFE8: _GLOBAL__sub_I_xml_oarchive.cpp (in boostLocation/lib/libboost_serialization.so.1.67.0)
==32375== by 0x400F8F2: _dl_init (in /usr/lib64/ld-2.17.so)
==32375== by 0x4001159: ??? (in /usr/lib64/ld-2.17.so)
==32375== by 0x6: ???
==32375== by 0x1FFEFFFAE6: ???
==32375== by 0x1FFEFFFB38: ???
==32375== by 0x1FFEFFFB3B: ???
==32375== by 0x1FFEFFFB54: ???
==32375== by 0x1FFEFFFB57: ???
==32375== by 0x1FFEFFFB59: ???
==32375== by 0x1FFEFFFB5C: ???
==32375==
==32375== LEAK SUMMARY:
==32375== definitely lost: 0 bytes in 0 blocks
==32375== indirectly lost: 0 bytes in 0 blocks
==32375== possibly lost: 0 bytes in 0 blocks
==32375== still reachable: 528 bytes in 11 blocks
==32375== suppressed: 0 bytes in 0 blocks
==32375==
==32375== For counts of detected and suppressed errors, rerun with: -v
==32375== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
我知道仍然可以访问的内存“泄漏”并不总是一个大问题,但是我仍然想摆脱它们。另外,我不知道这些泄漏来自何处。它们似乎是在执行开始时由boost分配的内存,而我对此没有控制权。在计算机上编译boost时,我尝试使用调试符号编译boost,以便valgrind可以向我显示行号或更详细的堆栈跟踪,但是它不起作用,并且得到了完全相同的输出,执行{{ 1}}在.so文件上给了我很多输出,因此我相信它包含符号,但是valgrind似乎并不在乎。
有人知道这些分配来自哪里吗?或者如何从boost源代码中获取更多信息?
子问题,即使线程实际上已加入并释放,我也有从Boost线程泄漏的问题。 Valgrind给了我以下跟踪:
objdump --debugging
我没有花很多时间处理最后一个错误,但是我仍然很乐意从valgrind获取更多信息...