<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">
<div class="moz-cite-prefix">Hello, Michal!</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Yes, the reference counter is
increased once, after the first call. After that, it remains the
same values.<br>
</div>
<div class="moz-cite-prefix">I think it would be very useful to
have the 'evict front from cache' function for cairo.</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Best,</div>
<div class="moz-cite-prefix">Vladimir</div>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">01.07.2021 00:09, Michal Sudolsky
пишет:<br>
</div>
<blockquote type="cite"
cite="mid:CABoc_45QiZevyOrU_rzp5WECq8F96JqAuBF546ehR+JQrx_fxg@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div>Hi,</div>
<div><br>
</div>
<div>I suppose it will not increase even further when
cairo_font_extents is called repeatedly. And after the 257th
or so font is loaded then the first will be properly released.
Cairo has a "holdover" cache which holds 256 entries.</div>
<div><br>
</div>
<div>There is a function to reset cairo state but you should not
use it (it is useful for example with valgrind).</div>
<div><br>
</div>
<div><a
href="https://www.cairographics.org/manual/cairo-Error-handling.html#cairo-debug-reset-static-data"
moz-do-not-send="true">https://www.cairographics.org/manual/cairo-Error-handling.html#cairo-debug-reset-static-data</a></div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Wed, Jun 30, 2021 at 9:47
PM Vladimir Sadovnikov <<a
href="mailto:sadko4u@gmail.com" moz-do-not-send="true">sadko4u@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">Hello all!<br>
<br>
I'm trying to work with custom fonts (loaded by freetype
library on Linux) <br>
within cairo library and noticed interesting thing.<br>
<br>
When I perform cairo_font_extents, the number of references
to the font becomes <br>
increased and the font becomes never freed after usage.<br>
<br>
What I mean.<br>
<br>
I perform the following code snippet:<br>
<br>
> cairo_font_extents_t fe;<br>
> cairo_set_font_face(cr, some_font);<br>
> cairo_font_extents(cr, &fe);<br>
> cairo_set_font_face(cr, NULL);<br>
<br>
Before calling first set_font_face, the
cairo_font_face_get_reference_count <br>
returns the value of 1, which is obviously correct since the
caller code is <br>
owner of the custom font.<br>
<br>
After calling the first set_font_face, the
cairo_font_face_get_reference_count <br>
returns the value of 1, which is correct, too.<br>
<br>
But after calling cairo_font_extents and before calling
second <br>
cairo_set_font_face, the cairo_font_face_get_reference_count
returns 4!<br>
<br>
After calling last cairo_set_font_face, I get the <br>
cairo_font_face_get_reference_count returning the value of
3.<br>
<br>
This is surprising behaviour for me (shouldn't the
cairo_font_extents release <br>
all acquired references before returning?)<br>
<br>
And this yields to the memory leakage when I actively
load/unload fonts since <br>
cairo doesn't ever release these fonts because of the
reference counter has been <br>
increased.<br>
<br>
Could you please explain what's happening and how to
properly unload fonts so <br>
cairo library could finally release them without any memory
leakage?<br>
<br>
<br>
Best,<br>
<br>
Vladimir<br>
<br>
<br>
<br>
-- <br>
cairo mailing list<br>
<a href="mailto:cairo@cairographics.org" target="_blank"
moz-do-not-send="true">cairo@cairographics.org</a><br>
<a
href="https://lists.cairographics.org/mailman/listinfo/cairo"
rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.cairographics.org/mailman/listinfo/cairo</a><br>
</blockquote>
</div>
</div>
</blockquote>
<p><br>
</p>
</body>
</html>