[cairo] memory leak with pycairo

Claudio Cilloni cilloni at callegari1930.com
Wed Jul 7 05:16:44 PDT 2010

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.move_to(100, 100)

        layout = cr.create_layout()
        layout.set_text('text text text')



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

More information about the cairo mailing list