[cairo] Issue with Font_Face reference count?

Chris Wilson chris at chris-wilson.co.uk
Tue Dec 16 02:14:45 PST 2008


On Mon, 2008-12-15 at 23:39 +0100, Anne et Damien Carbonne wrote:
> I store a pointer to the Ada wrapper (as well as a destroy function) on 
> the cairo side (C object), using user data.
> When ref count (on the cairo C side) is back to 0, cairo calls the 
> attached destroy function that frees the attached Ada wrapper.
> Except in the case I "discovered" (ref count nevers go back to 0, even 
> if application has called all necessaruy destroy functions, unless 
> cairo_debug_reset_static_data is called).
> But this is expected, as explained by Chris Wilson.

I wasn't entirely clear - the scaled font holdover cache is of finite
size. Eventually your old fonts will be flushed from the cache and you
will see the destroy notifier during the course of your application. The
only time you need to call cairo_debug_reset_static_data() is during
finalization and you are debugging memleaks using a tool like valgrind -
i.e. so we hide the false positives within cairo.

> Do you mean that I must implement my own ref counting on the Ada side, 
> in addition to the one implemented by cairo itself?

No. It sounds like you've implemented everything correctly, but were
just confused by the fact that cairo apparently never destroyed the
fonts during your test cases.

> This is indeed a solution to avoid usage of 
> cairo_debug_reset_static_data. I'm not sure it is worth.
> It is perfectly possible to accept that certain objects are not 
> destroyed at the end of main program by application itself (most OS 
> should do the job anyway). One only needs to know this, in order to do 
> the right thing, if necessary.
Exactly.
-- 
Chris



More information about the cairo mailing list