[PyQt] Memory leak

Giovanni Bajo rasky at develer.com
Thu Jul 3 15:04:42 BST 2008


Hi Phil,

with SIP 4.7.6, PyQt 4.2.2, Qt 4.4.0:

========================================
import sip
import weakref
from PyQt4.Qt import *

class MyWidget(QWidget):
     def sizeHint(self):
         return QSize(900, 700)

app = QApplication([])

ws = MyWidget(None)
wr = weakref.ref(ws)

L = QVBoxLayout(None)
L.addWidget(ws)
L.activate()
del L
del ws

import gc
gc.collect()

assert wr() is None
========================================

The assert triggers, meaning that the object of type MyWidget is not 
released.
-- 
Giovanni Bajo
Develer S.r.l.
http://www.develer.com


More information about the PyQt mailing list