我之前使用过valgrind,它非常有帮助。 我最近设置了一个开发环境并再次开始使用valgrind。 这次它发现没有丢失的记忆! 即使我malloc一些内存,然后用CTRL-C中断程序,我得到下面的转储。 有人可以解释发生了什么吗?


==2489== HEAP SUMMARY:
==2489==     in use at exit: 314,145 bytes in 585 blocks
==2489==   total heap usage: 1,410 allocs, 825 frees, 2,025,829 bytes allocated
==2489== LEAK SUMMARY:
==2489==    definitely lost: 0 bytes in 0 blocks
==2489==    indirectly lost: 0 bytes in 0 blocks
==2489==      possibly lost: 0 bytes in 0 blocks
==2489==    still reachable: 314,145 bytes in 585 blocks
==2489==         suppressed: 0 bytes in 0 blocks
==2489== Reachable blocks (those to which a pointer was found) are not shown.
==2489== To see them, rerun with: --leak-check=full --show-reachable=yes
==2489== For counts of detected and suppressed errors, rerun with: -v
==2489== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 6 from 6)

如果仍然有指向malloc ed内存的指针,那么它不是泄漏。 它显示在摘要中仍然可以访问


author: smparkes

参考更多解答: valgrind not catching obvious lost memory ,转载请保留出处valgrind没有捕获明显失去的记忆及作者信息

Statement: We respect knowledge and authors. Since the content comes from the Internet and is intended for scientific research, any reprinters should retain the author's signature and origin. If you are the author of the content and feel in dispute, please contact email: We will find out the situation and deal with it in time. We sincerely thank the author for his hard work.