簡體   English   中英

Valgrind:內存泄漏還是沒有?

[英]Valgrind: Memory leak or no?

我在程序上運行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)

無論我運行程序多長時間,無論是2秒還是2分鍾,這都是我從valgrind獲得的輸出。

由於“可能丟失”不會隨時間增加,因此可以安全地假設我沒有內存泄漏嗎?

這些錯誤似乎都來自libglib,並且圍繞着g_malloc0和g_realloc。

valgrind中Possibly lost錯誤涵蓋了涉及指針鏈的部分情形。 我肯定會追究造成這種情況的原因,直到您可以確認這不是問題為止(至少,您的內存占用不會增長),因為它可以指示代碼中的其他邏輯問題。

這篇文章的答案可以更詳細地解決它。

有關更多信息,您也可以查看valgrind手冊中的相關部分

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM