【发布时间】:2014-01-17 21:10:53
【问题描述】:
我正在我的程序上运行 valgrind,我得到以下输出(我将省略上面的 83 个错误,如果我应该将它们包含在日志中,请告诉我):
==9723== LEAK SUMMARY:
==9723== definitely lost: 0 bytes in 0 blocks
==9723== indirectly lost: 0 bytes in 0 blocks
==9723== possibly lost: 4,676 bytes in 83 blocks
==9723== still reachable: 88,524 bytes in 579 blocks
==9723== suppressed: 0 bytes in 0 blocks
==9723== Reachable blocks (those to which a pointer was found) are not shown.
==9723== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==9723==
==9723== For counts of detected and suppressed errors, rerun with: -v
==9723== ERROR SUMMARY: 83 errors from 83 contexts (suppressed: 3 from 3)
这是我从 valgrind 获得的输出,无论我运行程序多长时间,无论是 2 秒还是 2 分钟。
由于“可能丢失”不会随着时间的推移而增加,因此假设我没有内存泄漏是否安全?
这些错误似乎都来自 libglib,并围绕 g_malloc0 和 g_realloc。
【问题讨论】:
-
但是您的观察并不意味着您没有内存泄漏,只是您没有增长内存泄漏。
-
您的程序的内存占用是否会随着时间的推移而增长?
-
@Floris 我该如何解决?
标签: c linux memory-leaks valgrind