[PyQt] QTimer memory leek

Giovanni Bajo rasky at develer.com
Mon Oct 29 19:10:08 GMT 2007


On 10/28/2007 11:58 AM, Phil Thompson wrote:
> On Friday 26 October 2007, Никитин Артем wrote:
>> Hello,
>>
>> I got memory leak problem with QTimer (PyQt 4.3.1). Further, short example
>> to detect problem.
>>
>> import sys
>> from PyQt4 import QtCore, QtGui
>>
>> def schedule():
>>   QtCore.QTimer.singleShot(0, schedule)
>>
>> def main( ):
>>   qApp  = QtGui.QApplication(sys.argv)
>>   schedule()
>>   sys.exit(qApp.exec_())
>>
>> main()
> 
> This is a known feature but I agree that it's a problem in this particular use 
> case. Fixed in tonight's snapshot.

2007/10/28 10:51:13  phil
Universal proxy slots will now be reused when repeatedly connected to 
the same
Python slot so as not to leak memory in long running code.  The use case is
calling QTimer.singleShot() in a loop.


Mind detailing this a bit? Why is this fix necessary as not to leak 
memory? Shouldn't the universal slots be collected anyway, sooner or later?
-- 
Giovanni Bajo





More information about the PyQt mailing list