Graham Ashton wrote:
>Hi.
>
>I've been experimenting with libglade from Python, and have found that I
>can use up an awful amount of memory incredibly quickly by destroying
>and re-creating widgets. I've written a small script that demonstrates
>it.
>
>There is a small window with a label and a button on it. When you click
>the button the label gets replaced repeatedly with a new copy. It's the
>while loop in the recreate_label() function that does the replacement,
>and causes the memory gobbling.
>
>#!/usr/bin/env python
>#
># $Id$
>
>
>import gtk, libglade, time
>
>
>def recreate_label(signal, label, vbox):
> label.destroy()
> while 1:
> wtree = libglade.GladeXML("project1.glade", "label")
> label = wtree.get_widget("label")
> vbox.pack_start(label)
> vbox.reorder_child(label, 0)
> label.destroy()
>
>
>if __name__ == "__main__":
> wtree = libglade.GladeXML("project1.glade", "window1")
> window = wtree.get_widget("window1")
> button = wtree.get_widget("button")
> button.signal_connect("clicked", recreate_label,
> wtree.get_widget("label"),
> wtree.get_widget("vbox1"))
> window.show()
> gtk.mainloop()
>
>If anybody would like the Glade file that goes with it to play around,
>drop me a line and I'll post it. It's only short.
>
>So my question is - am I doing something wrong (most likely), or is this
>a leak? I'm using the latest stable pygnome (i.e. on GNOME 1.4), with
>Python 2.2, all compiled from source.
>
>
If you could run this under memprof to see which allocations are using
the most memory? What if you change the labe.destroy() calls to this?:
vbox.remove(label)
If you feel like it, you could also try the latest pygtk 1.99.x release
to see if it has the same problem (much of the code has been rewritten
for the 2.0 release of both pygtk and libglade).
James.
--
Email: [EMAIL PROTECTED]
WWW: http://www.daa.com.au/~james/
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/