[cairo] memory leak in _cairo_pattern_create_solid

Chris Wilson chris at chris-wilson.co.uk
Fri Oct 12 04:27:09 PDT 2007


Nguyen Vu Hung (vuhung16plus at gmail.com) said: 
> The next cairo API that I am having problem with is cairo_show_text().
> In my ( real production ) application, it has to call
> cairo_show_text() about 60,000,000 ( sixty millions ) times.
> For the following code, valgrind reports that cairo_show_text()
> creates an amount of 178,143 bytes memory leak.
> 
> Therefore, of course, if I call cairo_show_text() 60,000,000 times,
> the system will run out of memory.
> 
> I've tried cairo_show_text() with cairo_debug_reset_static_data() but
> it didn't realease memory for me.
> 
> So what I have to do with cairo_show_text()'s mem leak?
> Is there anything similar to cairo_debug_reset_static_data that works
> with cairo_show_text()?

Yes, what you see being reported here is the cache maintained by
fontconfig, which can be released with FcFini(). What's being cached
here is parsed configuration data and file/directory indexes, so it
is allocated just once and re-used.

Once you are used to handling text using the 'toy' API, you should
perhaps look at using Pango, and its pangocairo interface, as it handles
the layout (including the loading of the correct fonts) of complex
scripts. I've attached an example of using pangocairo to show how easy
it is to get started.
--
Chris Wilson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: utf8test-pango.c
Type: text/x-csrc
Size: 1569 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20071012/738fb153/attachment.c 


More information about the cairo mailing list