[PyKDE] Bad Memory Leak

Andreas Pakulat apaku at gmx.de
Wed Dec 6 10:25:40 GMT 2006

On 06.12.06 06:37:06, Andre Reitz wrote:
> Hello all, not really sure if I
> am right here with my problem, but there is a
> great Memoryleak:
> --------------------------------------------------
> >from qt import *
> app=QApplication([])
> def c():
> 	print "cc"
> sss=SIGNAL("clicked()")
> while 1:
> 	d=QDialog()
> 	b=QPushButton("x",d)
> 	QObject.connect(b,sss,c) #<-------XXX
> 	d.exec_loop()
> 	del b
> 	del d
> --------------------------------------------------
> Stay on the escape key, so that many many dialogs
> will be created and deleted.

My guess would be that the Python Garbage collector just doesn't run
often enough to free the memory.

Note this is python, not C++, del foobar doesn't immediately free the
memory associated.

And last but not least: Who on earth creates such code in practice? If
anybody does he deserves slapping.

Another thing could be that a reference to the dialog or the pushbutton
is held "somewhere" by the code that connect() executes. But this is
sth. Phil has to comment on.

> Problem occurs on linux (PyQt-3.5.1-19 (SuSE))

3.5.1? Thats more than ancient.

> and on Windows (PyQt-3.11 and PyQt-3.14)

Well, these are also old versions, PyQt-3.17.


Your object is to save the world, while still leading a pleasant life.

More information about the PyQt mailing list