[PyKDE] Re: Memory leak & segfault with deleteLater
Phil Thompson
phil at riverbankcomputing.co.uk
Sat Jun 25 16:48:42 BST 2005
On Monday 20 June 2005 4:15 pm, Giovanni Bajo wrote:
> The second problem is a memory leak:
> >>> from qt import *
> >>> app = QApplication([])
> >>> import gc, weakref
> >>> class Data:
>
> ... pass
> ...
>
> >>> d = Data()
> >>> wd = weakref.ref(d)
> >>> w1 = QWidget(None)
> >>> w2 = QWidget(w1)
> >>> w2.xxxxxx = w1
> >>> w1.xxxxxx = d
> >>> del d
> >>> del w1
> >>> del w2
> >>> gc.collect()
>
> 0
>
> >>> app.processEvents()
> >>> gc.collect()
>
> 0
>
> >>> print wd
>
> <weakref at 00813690; to 'instance' at 00812FD0>
>
> "d" should be collected as w1 and w2 are destroyed.
Should be fixed in tonight's SIP snapshot. The cyclic garbage collector was
ignoring the extra reference to wrappers of objects owned by C++.
Phil
More information about the PyQt
mailing list