Cairo and memory leaks fix with valgrind

邮差的信 提交于 2019-12-11 01:28:20

问题


In my program, even if do all the obvious housekeeping, such as calling cairo_destroy(), cairo_surface_destroy()..., valgrind always finds memory leaks, the leaks are in cairo dependencies (freetype, pixman, ...). How do I cleanup after cairo, so that valgrind won't detect any leaks, or are the leaks normal?

Sample output

==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:

This question says, the "leaks" are normal, does there exist a way to do the cleanup, so valgrind becomes happy?


回答1:


For cairo there is cairo_debug_reset_static_data().

While writing this as a comment, I was looking into pixman's source and the implementation of _pixman_choose_implementation() and apparently you cannot "clean up" pixman.

I have no clue about freetype.

Edit: For fontconfig (related to freetype, so possibly interesting here), there is FcFini().



来源:https://stackoverflow.com/questions/22750611/cairo-and-memory-leaks-fix-with-valgrind

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!