Can I explicitly request garbage collection from C?

Courageous jkraska1 at san.rr.com
Wed Jun 7 22:04:13 EDT 2000


Alex wrote:
> 
> Hi.
> 
> I am having a little trouble keeping track of reference counts in C
> extensions.  I thought it would be helpful if I could call garbage
> collection from an arbitrary point in my program and check what was
> destroyed.  Is that possible?

Things are destroyed instantly when their reference counts reach
zero. There's a function somewhere that prints out an object's
reference count; that's probably what you want. Either that, or
if you're writing a C extension, you can examine the object's
reference count directly. In virtually all cases, it will be
one higher than you expect, because the tuple that was sent as
an argument to your external function also happens to own a
reference to your object.

C/



More information about the Python-list mailing list