[PyQt] sip: Member objects and GC

Phil Thompson phil at riverbankcomputing.com
Thu Mar 8 22:28:19 GMT 2012

On Thu, 08 Mar 2012 23:14:49 +0100, Jonathan Kleinehellefort <jk at molb.org>
> On Thu, 08 Mar 2012 10:03:46 +0000, Phil Thompson
> <phil at riverbankcomputing.com> wrote:
>> Even if there is a reference cycle the garbage collector should break
>> if it is being allowed to run. Any test should explicitly invoke it.
> Not sure if this applies here, but I think the Python GC will not call
> destructors on objects that are part of a reference cycle.  So maybe the
> Python wrappers get collected but not the C++ objects.

No. The GC won't collect objects with __del__ methods.

>> Can you provide such a test that demonstrates the problem?
> You can already see it in the original test I put up on my webserver.
> But I updated it to make it more explicit:
>     http://molb.org/~jk/siptest2.tar.gz
> The C++ objects have destructors that should print stuff, but that never
> happens.

...because the GC isn't being run. Import the gc module and run it

> Another thing: it would be nice if sipKeepReference() would appear in
> docs.

It's not part of the public API.


More information about the PyQt mailing list