开罗和内存泄漏用valgrind修复 [英] Cairo and memory leaks fix with valgrind
问题描述
在我的程序中,即使所有明显的内务处理,例如调用 cairo_destroy()
, cairo_surface_destroy()
..., valgrind
总是会发现内存泄漏,这些泄漏在 cairo
依赖项中( freetype
, pixman
,...)。 cairo
之后如何清理,以使 valgrind
不会检测到任何泄漏,或者泄漏正常吗? / p>
样本输出
== 1861 ==堆摘要:
== 1861 ==退出时正在使用:532个块中的1,996,663字节
== 1861 ==总堆使用量:21,915个分配,21,383个空闲,95,411,698个字节已分配
== 1861 ==
== 1861 ==泄漏摘要:
== 1861 ==绝对丢失:0个字节(0块)
== 1861 ==间接丢失:0个字节(0个块)
== 1861 ==可能丢失:0个字节,共0个块
== 1861 ==仍可访问:1,996,663字节,共532个块
== 1861 ==被抑制:0个字节,共0个块
== 1861 ==未显示可到达的块(找到指针的块)。
== 1861 ==要查看它们,请重新运行:--leak-check = full --show-leak-kinds = all
== 1861 ==
== 1861 ==有关检测到的和抑制的错误的计数,请重新运行:-v
== 1861 ==使用--track-origins = yes可以查看未初始化的值来自
== 1861 ==的错误摘要:1961来自7个上下文的错误(禁止:1个中的1个)
UPDATE:
这个问题说,泄漏是正常,是否存在进行清理的方法,所以valgrind变得很高兴?
对于开罗,有 cairo_debug_reset_static_data()
。
在写这篇文章作为评论时,我在研究pixman的源码和 _pixman_choose_implementation()
,显然您无法清理 pixman。
我对freetype一无所知。
编辑:
为fon tconfig(与freetype相关,所以在这里可能很有趣),有 FcFini()
。
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?
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()
.
这篇关于开罗和内存泄漏用valgrind修复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!