[cairo] memory leak with pycairo
Steve
stevech1097 at yahoo.com.au
Thu Jul 8 03:34:46 PDT 2010
On Wed, 2010-07-07 at 10:36 -0700, cairo-request at cairographics.org
wrote:
>
> Hi All.
>
> I'm experiencing a case of memory leak inside my application; I
> realized that
> process virtual memory grows while rendering text.
>
> I extracted this test case:
>
> --------------------------------------------------------------------
> import sys, os, gc
> import pango
> import cairo
> import pangocairo
>
> if __name__ == '__main__':
>
> surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 400, 300)
> cr = pangocairo.CairoContext(cairo.Context(surface))
> cr.set_source_rgb(1.0, 0.0, 0.0)
>
> for i in xrange(500000):
>
> cr.new_path()
> cr.move_to(100, 100)
>
> layout = cr.create_layout()
> layout.set_text('text text text')
>
> cr.show_layout(layout)
>
> --------------------------------------------------------------------
>
> running this python program, I see the vm grow while the number of
> python
> objects remains constant (shown by adding 'print
> len(gc.get_objects())' inside
> the loop).
>
> I'm not so sure, but I think this could be a bug inside pycairo or
> something
> below it. Or am I forgetting to explicity release some resources?
>
> I'm running python-2.6.4, pycairo-1.8.8, cairo-1.8.8, pango-1.26.2 .
>
> thank you for your support.
> Claudio Cilloni
Claudio
I can see the memory usage increase, so there may be a memory leak.
There is only one object created in the loop - the layout - so it may be
a problem with pangocairo (which is part of pygtk, I believe).
Steve
More information about the cairo
mailing list