[PyQt] Problems freeing objects
Albert Cervera i Areny
albert at nan-tic.com
Sat Mar 7 10:57:15 GMT 2009
A Dissabte 07 Març 2009, Andreas Pakulat va escriure:
> On 07.03.09 00:56:06, Albert Cervera i Areny wrote:
> > In my application the main interface is based on tabs. The problem is
> > that when I open a new tab I see memory increase but it does not decrease
> > when I close the tab.
> >
> > I've been looking at this and I try to remove the widget from the
> > QTabWidget. Set its parent to None and remove its reference. The code
> > looks like this:
> >
> > wid = self.tabWidget.widget(tab)
> > self.tabWidget.removeTab( tab )
> > wid.setParent( None )
> > del wid
> > import gc
> > gc.collect()
> >
> > But that doesn't work. If I print gc.get_referrers( wid ) just before
> > "del wid" I get something like this the list below.
> > There, "Koo.Dialogs.FormWidget.FormWidget" is the widget in the tab
> > (wid), so it seems the only objects referring to the widget are the
> > reference itself (wid) and the methods it has.
> >
> > Does anybody know why I don't see memory being freed?
>
> How did you measure that? I suggest to use valgrind to find out wether
> you're leaking memory or not.
By the way, I forgot to mention that I
know "Koo.Dialogs.FormWidget.FormWidget" is not being freed because if I
print gc.get_objects() just after gc.collect(), the object is in the list. So
there's no need to run it with valgrind...
>
> Andreas
--
Albert Cervera i Areny
http://www.NaN-tic.com
More information about the PyQt
mailing list