[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] pyqt circular references & garbage collection
From: Phil Thompson <phil () riverbankcomputing ! co ! uk>
Date: 2007-07-31 21:44:03
Message-ID: 200707312244.03054.phil () riverbankcomputing ! co ! uk
[Download RAW message or body]
On Tuesday 31 July 2007 9:11 pm, charles chen wrote:
> Thanks Phil for your help with our memory lapse.
>
> We've come across another issue: the Python garbage collector isn't
> sussing out circular references properly.
>
> A previous post by you say that this should be working:
>
> http://www.riverbankcomputing.com/pipermail/pyqt/2007-May/016237.html
>
> Here's a simple demonstration:
> >>> from PyQt4.QtCore import QObject
> >>> class q(QObject):
>
> ... def init(self):
> ... QObject.init(self)
> ... def __del__(self):
> ... print 'q deleted.'
> ...
>
> >>> q1 = q()
> >>> q1 = None
>
> q deleted.
>
> >>> q2 = q()
> >>> q2.circularReference = q2
> >>> q2 = None
> >>> q3 = q()
> >>> q3.circularReference = q3
> >>> q3.deleteLater()
> >>> q3 = None
> >>> import gc
> >>> gc.collect()
>
> 0
>
> >>> q4 = q()
> >>> q4.circularReference = q4
> >>> q4.circularReference = None
> >>> q4 = None
>
> q deleted.
>
> q2 and q3 are never gc'ed.
>
> We're also seeing this in production. Are we doing something wrong?
I don't believe that the garbage collector operates on classes that have a
__del__ method. See the comments in gcmodule.c in the Python source code.
Phil
_______________________________________________
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