[cairo] memory leak in _cairo_pattern_create_solid

Carl Worth cworth at cworth.org
Tue Oct 16 13:46:06 PDT 2007


On Tue, 16 Oct 2007 21:39:20 +0200, "=?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=" wrote:
>
> Isn't it that that is the core of the problem? A finalizer should of
> course not try to free something that something else references.

Not a problem, no.

We put the checks in there intentionally because they are extremely
useful when debugging.

If your application inadvertently holds on to a reference, (a leak),
and the referenced object also happens to be in a cache, then it's
really hard to find out about the leak, (valgrind just reports the
memory as still-reachable for example).

So what we provide is the ability for the application author to first
clean up all references, then call cairo_debug_reset_static_data and
if the cache finds that any objects are still referenced then there's
definitely a bug somewhere. This seems extremely useful to me.

I suppose cairo could be silent about that and let the user look
closely at any still-reachable memory after calling
cairo_debug_reset_static_data. But since cairo must actually detect
this error condition it seems only useful to report it when it finds
it, (particularly since it's inside a debugging-only function).

So that's the rationale of the current possible assertion in
cairo_debug_reset_static_data. So anybody putting effort into making
that not a debugging-only function will need to keep that in mind.

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20071016/7ef736e3/attachment-0001.pgp 


More information about the cairo mailing list