[PyKDE] QObject deletion, die

Mikael Schönenberg schonenberg at gmail.com
Sun Sep 4 11:14:06 BST 2005


On 9/4/05, Patrick Stinson <patrickkidd at gci.net> wrote:
> 
> deleting QObject/QWidget objects has never been easy. But, why is it
> that the amount of memory used by the following code is not stable?
> 
> for i in range(10000000000):
> o = QObject()
> print 'done'
> 
> 
> the process memory steadily rises to 700M+, then the app dies.



Because you're creating a python list of 10,000,000,000 elements before even 
involving Qt. Try using xrange() instead of range(). If you do so, you'll 
notice that the memory consumption is rather stable.

On my machine, creating 10 million QObjects took roughly 30 seconds. You're 
trying to create 1000 times as many, so unless you've got an extremely fast 
machine, I'd suggest lowering that number if you ever want to see the output 
from that print statement :)

-- 
Mikael Schönenberg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20050904/a3417f83/attachment.html


More information about the PyQt mailing list