[cairo] memory leak in _cairo_pattern_create_solid

Behdad Esfahbod behdad at behdad.org
Tue Oct 16 09:27:33 PDT 2007

On Tue, 2007-10-16 at 12:08 -0400, BJörn Lindqvist wrote:
> On 10/12/07, Chris Wilson <chris at chris-wilson.co.uk> wrote:
> > The 'leak' is intentional as we keep a few solid patterns around to avoid
> > having to continually allocate new patterns. In order to free up this
> > and other static caches cairo maintains, call
> > cairo_debug_reset_static_data() whilst exiting your code. You must be
> > sure that you have released all of your own cairo objects - contexts,
> > surfaces, patterns, fonts - before calling
> > cairo_debug_reset_static_data().
> Why can't cairo use a shared object finalizer to clean up after
> itself? Something like this:
> void
> __attribute__ ((destructor))
> cairo_died (void)
> {
>     cairo_debug_reset_static_data ();
> }
> I too have been puzzled by libraries leaving static caches around.

Because there's not much point in doing that other than slowing down
application shutdown.  And of course it's not portable and all...

Though now that you bring it up, I don't mind marking
cairo_debug_reset_static_data() with __attribute__ ((destructor)).
Carl, objections?


"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759

More information about the cairo mailing list