在我的計劃,即使做所有的看家明顯,如呼叫cairo_destroy()
,cairo_surface_destroy()
... valgrind
總會發現內存泄漏,泄漏是cairo
依賴(freetype
,pixman
。 ..)。如何在cairo
之後進行清理,以便valgrind
不會檢測到任何泄漏或泄漏是否正常?開羅和內存泄漏修復與Valgrind的
樣本輸出
==1861== HEAP SUMMARY:
==1861== in use at exit: 1,996,663 bytes in 532 blocks
==1861== total heap usage: 21,915 allocs, 21,383 frees, 95,411,698 bytes allocated
==1861==
==1861== LEAK SUMMARY:
==1861== definitely lost: 0 bytes in 0 blocks
==1861== indirectly lost: 0 bytes in 0 blocks
==1861== possibly lost: 0 bytes in 0 blocks
==1861== still reachable: 1,996,663 bytes in 532 blocks
==1861== suppressed: 0 bytes in 0 blocks
==1861== Reachable blocks (those to which a pointer was found) are not shown.
==1861== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==1861==
==1861== For counts of detected and suppressed errors, rerun with: -v
==1861== Use --track-origins=yes to see where uninitialised values come from
==1861== ERROR SUMMARY: 1961 errors from 7 contexts (suppressed: 1 from 1)
UPDATE:
這question稱, 「漏」 是正常的,不存在一個方式做清理工作,所以Valgrind的變得快樂呢?
我沒有看到任何泄漏:'絕對丟失,間接丟失,可能丟失:0個字節0字節'。 –
@MartinJames是的,但在理想的世界裏,所有分配的堆將在程序退出時被釋放。這就是我想要達到的目標。 – user1095108
對於cairo,有cairo_debug_reset_static_data()。 –