A Seg, 2003-12-08 �s 03:02, Jeff Bowden escreveu:
> I can't find anything in the API to tell it to let go and just letting
> pixbuf object go out of scope doesn't seem to do the trick. I have a
> picture thumbnail display list that just eats up memory until the OOM
> killer gets it. It loads the images using gtk.gdk.pixbuf_new_from_file
> and then creates a rescaled copy using scale_simple. The rescaled copy
> is then passed to an ListStore.append.
>
> I suppose it's possible that the (smaller) copy is somehow the same size
> as the original, which would explain the memory consumption, so the bug
> might be in scale_simple. But I was just wondering if this is a known
> problem or what. I can't find anything about it other than an
> unanswered message to this list a few months ago.
I've add some instrumentation to the pixbuf wrapper code. Here's what
I discovered:
>>>
pb=gtk.gdk.pixbuf_new_from_file("/usr/share/pixmaps/gnome-emacs.png")
** Message: pixbuf 0x8154b48 created, grefcount=1
>>> del pb
>>>
>>> import gc
>>> gc.collect()
** Message: pixbuf 0x8154b48 destroyed
1
>>>
The problem is that Python's garbage collector only kicks in after a
certain amount of objects are in the 'garbage' list. So, you can
explicitly call gc.collect() periodically, or you can change the gc
threshold with gc.set_threshold().
I think that Python's gc module is tune for lots of objects taking
small amount of memory each. In your case, you have few objects taking
a huge amount of memory each. That's why the GC isn't working very
well.
I suggest you consult the documentation for the gc module. If you
solve the problem, please let us know or write a small FAQ entry about
it. Thanks!
Regards.
--
Gustavo J. A. M. Carneiro
<[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/