[pygtk] memory leak !?

Natan Zohar nnzohar at acm.org
Wed Jun 14 04:46:09 WST 2006


Adrian,

    I have had a similar problem in the past. I did some research into
it and found out you need to garbage collect manually after you no
longer have references to the image. I don't remember why I did this,
but I have something like this in my code:

import gc
gc.enable()
...
set_image(someimage):
    # set the image
    gc.collect()

I hope this helps you.

Natan

On Tue, 13 Jun 2006 22:02:30 +0200
Adrian Immler <pygtk at dedicated.12mm.net> wrote:

> hello list,
> 
> today i wrote a small script for viewing images (similar to "eye of
> gnome"). i noticed that when looking through an image archive of
> large images (one image between 2 and 3 mb) that the script consumes
> more and more memory with each image. with images at that size it
> takes not more than 20 images until the program terminates and
> outputs a "killed" to the console. this happens on my system with
> only 512mb ram at about 80mb ram usage for the script.
> 
> i have no idea why this happens and would like to know if you guys
> out there got any idea. i also need to mention that on my system at
> work i could not reproduce this error (but i use an older version of
> gtk and pygtk at work) i have attached the script to this email.
> start it like "imageviewer /path/to/image" where also enough other
> images reside in the same folder und use the back and forward buttons.
> 
> the script is less than 150 lines of code and very readable.
> 
> i have these versions installed:
> 
> pkg-config --modversion gtk+-2.0
> 2.8.18
> pkg-config --modversion pygtk-2.0
> 2.8.6


More information about the pygtk mailing list