[pygtk] Re: Pixbuf memory leak?

Loris Caren loris at caren.demon.co.uk
Wed Nov 16 17:06:10 WST 2005


On Tuesday 15 November 2005 21:06, you wrote:
> I'm doing a large number of calls to
> p = gtk.gdk.pixbuf_new_from_file(f)
> ...
> del p
> and am finding that the process consumes more and more memory as it
> goes on.  Should I expect the del to free up the memory used by the
> loaded image, or is there some kind of 'close' call I need to be
> invoking first?
Think I've found the answer to this one in the archives. Various other 
people have reported a similar bug, but 
http://article.gmane.org/gmane.comp.gnome.gtk+.python/2315/match=pixbuf
suggests it's an issue with the garbage collector. Adding an explicit 
gc.collect() after my del stops my memory usage wandering off the 
scale.  This looks like a generic issue for anyone manipulating lots 
of large objects, and an easy trap for those that thought that python 
'just did' memory allocation and one never need bother about it.


More information about the pygtk mailing list