[PyQt] Problems freeing objects
Albert Cervera i Areny
albert at nan-tic.com
Fri Mar 6 23:56:06 GMT 2009
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?
<frame object at 0xb53360c>
<bound method FormWidget.autoReload of <Koo.Dialogs.FormWidget.FormWidget
object at 0xa4b09ac>>
<bound method FormWidget.showLogs of <Koo.Dialogs.FormWidget.FormWidget object
at 0xa4b09ac>>
<bound method FormWidget.showAttachments of <Koo.Dialogs.FormWidget.FormWidget
object at 0xa4b09ac>>
<bound method FormWidget.goto of <Koo.Dialogs.FormWidget.FormWidget object at
0xa4b09ac>>
<bound method FormWidget.duplicate of <Koo.Dialogs.FormWidget.FormWidget
object at 0xa4b09ac>>
<bound method FormWidget.next of <Koo.Dialogs.FormWidget.FormWidget object at
0xa4b09ac>>
<bound method FormWidget.reload of <Koo.Dialogs.FormWidget.FormWidget object
at 0xa4b09ac>>
<bound method FormWidget.switchView of <Koo.Dialogs.FormWidget.FormWidget
object at 0xa4b09ac>>
<bound method FormWidget.export of <Koo.Dialogs.FormWidget.FormWidget object
at 0xa4b09ac>>
<bound method FormWidget.import_ of <Koo.Dialogs.FormWidget.FormWidget object
at 0xa4b09ac>>
<bound method FormWidget.massiveUpdate of <Koo.Dialogs.FormWidget.FormWidget
object at 0xa4b09ac>>
<bound method FormWidget.new of <Koo.Dialogs.FormWidget.FormWidget object at
0xa4b09ac>>
<bound method FormWidget.save of <Koo.Dialogs.FormWidget.FormWidget object at
0xa4b09ac>>
<bound method FormWidget.search of <Koo.Dialogs.FormWidget.FormWidget object
at 0xa4b09ac>>
<bound method FormWidget.previous of <Koo.Dialogs.FormWidget.FormWidget object
at 0xa4b09ac>>
<bound method FormWidget.remove of <Koo.Dialogs.FormWidget.FormWidget object
at 0xa4b09ac>>
--
Albert Cervera i Areny
http://www.NaN-tic.com
More information about the PyQt
mailing list