开罗和内存泄漏修复了valgrind

在我的程序中,即使执行所有明显的内务处理,例如调用cairo_destroy()cairo_surface_destroy() …, valgrind总是发现内存泄漏,泄漏都是cairo依赖( freetypepixman ,…)。 如何在cairo之后进行清理,以便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) 

更新:

这个问题说,“泄漏”是正常的,有没有办法进行清理,所以valgrind会变得幸福吗?

对于cairo,有cairo_debug_reset_static_data()

在写这篇评论时,我正在研究pixman的源代码和_pixman_choose_implementation()的实现,显然你不能“清理”pixman。

我对freetype一无所知。

编辑:对于fontconfig(与freetype相关,这里可能很有趣),有FcFini()