[cairo] Memory leaks

Malcolm Tredinnick malcolm at pointy-stick.com
Fri Jan 23 18:27:20 PST 2009

On Fri, 2009-01-23 at 09:43 -0500, cu wrote:
> Good day!
> I am using Cairo under windows, drawing into image surfaces. I have 
> tested the application with Visual Leak detector and it shows fairly 
> numerous memory leaks in Cairo functions, in particular down the path in 
> functions called from cairo_fill, but also others (text drawing etc). 
> Some of these objects appear to be ref counted. Considering amount of 
> reported leaks and assuming VLD is correct (it had been so far) I wonder 
> if it may be something I don't do in my code that causes memory to leak?
> Is there anything aside from cairo_destroy and cairo_surface_destroy 
> that needs to be done to deallocate resources?
> I am using cairo-1.8.6, compiled from sources locally.

Cairo does a lot of caching behind the scenes. The memory used there is
returned upon program termination, but memory tracers don't necessarily
know that. If you're looking for memory leaks, you also need to insert a
call to cairo_debug_reset_static_data() (see [1]).

You only need that for a build you're using to check for memory leaks.
Again, the memory reclaimed by that call is *not* leaked when you don't
call that function. It is reclaimed at termination. It's only a
workaround for memory checkers.



More information about the cairo mailing list