[PyKDE] qt or python memory leak?

Simon Edwards simon at simonzone.com
Sun Mar 14 12:10:01 GMT 2004

On Sun, 14 Mar 2004 01:17 am, Patrick Stinson wrote:
> why is it that the amount of memory that the following script uses does not 
> remain constant?
> (mem usage does not change if 'WDestructiveClose'/'w.close()' are omitted)
> a = QApplication([])
> class W(QWidget):
>     def __init__(self):
>         QWidget.__init__(self, None, None, Qt.WDestructiveClose)
> while 1:
>     w = W()
>     w.close()

Taking a wild guess, because w.close() doesn't actually free any memory. 
Apparently deleting the "this" (of "self" in python) in C++ from inside a 
method is a big No-No. w.close() probably cues up w for destruction by Qt the 
next time Qt enters its event loop. Your code never enters the event loop, so 
your w is never fully deleted.


Simon Edwards             | Guarddog Firewall
simon at simonzone.com       | http://www.simonzone.com/software/
Nijmegen, The Netherlands | "ZooTV? You made the right choice."

More information about the PyQt mailing list