[PySide] QTimer reference leaks in pyside vs pyqt

Stefan Champailler schampailler at skynet.be
Mon Jun 9 20:09:32 CEST 2014

On Mon, 9 Jun 2014 07:45:32 -0400
Josh Pieper <jjp at pobox.com> wrote:

Is it me or this can produce that kind of stack :

    timer triggers and goes to test instantly
	    timer triggers and goes to test instantly
		    timer triggers and goes to test instantly

Although it may work I'd say it's somehow risky

But that's just my humble opinion, I've never written such code, I
use QTimer instances with intervals > 100ms...


> Hello, I have an application that wants to repeatedly schedule
> callbacks into the QT event loop.  With pyside, memory usage grows
> over time, as python doesn't appear to be able to free things up.
> objgraph shows a growing number of QTimer objects not being collected.
> With pyqt, this is not a problem, and neither is it with a C++
> transliteration.
> I'm using pyside 1.2.1 on ubuntu 14.04.  My demonstration application
> is below.  It is intended to busy loop, but with pyside, in addition,
> eventually uses all memory on the machine.  If you replace PySide with
> PyQt4, it busy loops just fine, and memory usage does not increase at
> all over time.  I would have tried updating to 1.2.2, but it didn't
> look like any resource issues were mentioned in the release notes.
> Am I doing something wrong?
> Regards,
> Josh
> ----
> import sys
> import PySide.QtCore as QtCore
> def test():
>     QtCore.QTimer.singleShot(0, test)
> def main():
>     app = QtCore.QCoreApplication(sys.argv)
>     test()
>     app.exec_()
> if __name__ == '__main__':
>     main()
> _______________________________________________
> PySide mailing list
> PySide at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/pyside

Timeo Danaos et dona ferentes
Twitter : @Arakowa1

More information about the PySide mailing list