[英]Summary of Valgrind : is there a memory leak in the output?
我的程序是用C ++編寫的,我運行valgrind來檢查內存問題。 但是,我不太確定,當您分配的內存多於釋放的內存時,會發生什么,但摘要指出沒有泄漏。 這是以下命令的輸出:
valgrind --leak-check=full ./myprogram
輸出(Centos 6):
==28196==
==28196== HEAP SUMMARY:
==28196== in use at exit: 66,748 bytes in 1 blocks
==28196== total heap usage: 7 allocs, 6 frees, 67,964 bytes allocated
==28196==
==28196== LEAK SUMMARY:
==28196== definitely lost: 0 bytes in 0 blocks
==28196== indirectly lost: 0 bytes in 0 blocks
==28196== possibly lost: 0 bytes in 0 blocks
==28196== still reachable: 66,748 bytes in 1 blocks
==28196== suppressed: 0 bytes in 0 blocks
==28196== Reachable blocks (those to which a pointer was found) are not shown.
==28196== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==28196==
==28196== For counts of detected and suppressed errors, rerun with: -v
==28196== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
Profiling timer expired
有人可以詳細介紹抑制問題嗎?
謝謝
仍然可以訪問意味着您有指向內存的指針,但是在關機之前沒有釋放它。 在大多數情況下,這意味着不會有問題的內存泄漏,因為在大多數情況下,這是您填充的數據結構,但在關機前並未釋放。
Valgrind檢測到的這個“ 仍然可達到的泄漏”問題在最高答案中有更多解釋。
編輯:詳細介紹抑制,valgrind可以讀取文件以抑制某些錯誤,並且此注釋從2抑制2表示從抑制的錯誤列表中也發現2個錯誤。 錯誤通常會被抑制,因為它們在第三方庫中或已知不會引起問題。 有關抑制錯誤的更多信息,請查看valgrind對錯誤抑制的說明 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.