On Mon, Dec 08, 2003 at 10:47:47AM -0800, Jeff Bowden wrote:
Are the pygtk developers on this list or is there a separate dev list somewhere?
We're on the list, but we're hiding from you!
More seriously, I've asked Gustavo and he says there doesn't appear to
be a leak in your case -- it could just be a case of Python's
"interesting" gc behaviour. So we're suggesting you add a
gc.collect() call inside your loop and seeing if it improves. If it
does, you're entitled to write a FAQ that explains your problem and
solution <wink>.
(If not, we'll still be hiding here if you need us.)
Thanks. It does appear that it is a python gc problem. Here's my new FAQ entry (still awaiting password):
*23.16. Is there a resource leak? Why do I run out of memory using Pixbuf?*
The answer is "Interesting GC behaviour" in Python. Apparently finalizers are not necessarily called as soon as an object goes out of scope. My guess is that the python memory manager doesn't directly know about the storage allocated for the image buffer (since it's allocated by the gdk) and that it therefor doesn't know how fast memory is being consumed.
The solution is to call gc.collect() at some appropriate place.
For example, I had some code that looked like this:
for image_path in images:
pb = gtk.gdk.pixbuf_new_from_file(image_path)
npb = pb.scale_simple(thumb_width, thumb_height, gtk.gdk.INTERP_BILINEAR)
thumb_list_model.set_value(thumb_list_model.append(None), 0, npb)
This chewed up an unacceptably large amount of memory for any reasonable image set. Changing the code to look like this fixed the problem:
for image_path in images:
pb = gtk.gdk.pixbuf_new_from_file(image_path)
npb = pb.scale_simple(thumb_width, thumb_height, gtk.gdk.INTERP_BILINEAR)
thumb_list_model.set_value(thumb_list_model.append(None), 0, npb)
gc.collect()
gc.collect()
_______________________________________________ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
