2014-03-30 34 views
2

在我的計劃,即使做所有的看家明顯,如呼叫cairo_destroy()cairo_surface_destroy() ... valgrind總會發現內存泄漏,泄漏是cairo依賴(freetypepixman。 ..)。如何在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的變得快樂呢?

+1

我沒有看到任何泄漏:'絕對丟失,間接丟失,可能丟失:0個字節0字節'。 –

+0

@MartinJames是的,但在理想的世界裏,所有分配的堆將在程序退出時被釋放。這就是我想要達到的目標。 – user1095108

+1

對於cairo,有cairo_debug_reset_static_data()。 –

回答

4

對於開羅有cairo_debug_reset_static_data()

在寫這篇評論的時候,我正在研究pixman的源碼和_pixman_choose_implementation()的實現,顯然你不能「清理」pixman。

我對freetype沒有任何線索。

編輯: 對於fontconfig(與freetype有關,所以這裏可能有趣),有FcFini()

+0

這將必須做,除非有人提出更好的東西。 – user1095108

+0

我建立並鏈接FreeType獨立於開羅,並且當我的程序終止時,我沒有可到達的FreeType塊,只剩下pixman塊。 –