[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] PyQt4 memory leak
From:       David Aguilar <davvid () gmail ! com>
Date:       2013-08-09 10:08:56
Message-ID: CAJDDKr7BRuqZqA0RmGXnZ8rpbZ9OewuyoTzGOCcWWWphguh9Ng () mail ! gmail ! com
[Download RAW message or body]

On Wed, Jul 31, 2013 at 9:46 PM, David Aguilar <davvid@gmail.com> wrote:
> On Fri, Jul 19, 2013 at 3:06 AM, Phil Thompson
> <phil@riverbankcomputing.com> wrote:
>> On Mon, 15 Jul 2013 22:27:45 -0700, David Aguilar <davvid@gmail.com>
>> wrote:
>>> Matti Aarnio reported a memory leak in git-cola that I traced back to
>>> PyQt4.
>>>
>>> I've attached a minimal reproducer.
>>>
>>> I've tested this on Mac OS X and Debian/testing with PyQt4 4.9.x.
>>>
>>> Matti's tried it on x86_64 Fedora 18, we see the same behavior there.
>>>
>>> Everytime we hit the "Refresh" button more memory is consumed and
>>> never returned.
>>>
>>> Is there anything we can do differently to allow the widgets to get
>>> cleaned up?
>>>
>>> The add_items() call uses treewidget.takeItems() to make the old items
>>> go away, and then adds new items.  The old items do not seem to be
>>> getting cleaned up.
>>
>> It's a SIP code generation bug - fix in tonight's snapshot.
>>
>> A workaround may be to remove the items individually...
>>
>>     while root.takeChild(0) is not None:
>>         pass

BTW Qt is really slow when removing from the front of the array.

I ended up doing this instead:

    count = root.childCount()
    while count > 0:
        root.takeChild(count-1)
        count = root.childCount()

The performance profile suggests that Qt shifts subsequent items when
takeChild(0) is used, so taking from the end is fastest.

Thanks,
-- 
David
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic