[cairo] memory leak in _cairo_pattern_create_solid

Behdad Esfahbod behdad at behdad.org
Tue Oct 16 15:07:31 PDT 2007


On Tue, 2007-10-16 at 10:39 -0700, Carl Worth wrote:
> On Tue, 16 Oct 2007 12:27:33 -0400, Behdad Esfahbod wrote:
> > 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?
> 
> "There's no point in doing it... but we should do it" ? I don't
> follow.

Well, "now that we almost have code for it, lets do it".


> In general, I agree with your point that this will just slow down
> application shutdown. There's a reason we put "debug" into the name of
> this function---it's really only meant to be called while debugging.
> 
> But there's another issue which is that unconditionally calling
> cairo_debug_reset_static_data will emit error messages unless the
> application has first carefully cleaned up everything, (not holding an
> references to cached data). In development-mozilla code has been in
> this state for a while, (it would call cairo_debug_reset_static_data
> without having done all cleanup and trigger an assertion failure crash
> while exiting).
> 
> So I don't think it's a good idea. (Plus, it might tempt someone to
> start depending on the "destructor" behavior within cairo's
> implementation, but it's not at all portable.)
> 
> > On Tue, 2007-10-16 at 12:08 -0400, BJörn Lindqvist wrote:
> >
> > > I too have been puzzled by libraries leaving static caches around.
> 
> Yeah, it can be confusing. And that's exactly why we provide
> cairo_debug_reset_static_data. Maybe we can advertise that better
> someplace.

What about by default just releasing references from caches at shutdown,
but asserting if cairo_debug_reset_static_data() is called.  That way
people will get valgrind reports only for their own leaks.

However, thinking about it again, it's not easy.  When releasing scaled
fonts and glyphs, we'll end up queuing work for the X server (assuming
XCloseDisplay is not called), and can't free that memory safely.  We
sure *can*, but it's not clean.

> -Carl
-- 
behdad
http://behdad.org/

"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