[Python-Dev] Python GC/type()/weakref mystery (original) (raw)

Aahz aahz at pythoncraft.com
Thu Mar 18 13:02:19 EST 2004


On Thu, Mar 18, 2004, Kevin Jacobs wrote:

Aahz wrote:

This looks to me like standard boundary conditions for GC; GC normally only gets provoked when more than gc.getthreshold() objects have been created than deleted. What makes you think something unusual is happening? I realize that this does look like standard GC threshold behavior However, it /shouldn't/, because I manually run gc.collect() both before and after the test suite. The other thing that is strange is that all of these dead weakrefs disappear when I run gc.collect() as part of each iteration of the test suite, but not afterwards. Please read over my original mail again, since the magnitude of weirdness may not have been obvious the first time through.

Hmmmm... First of all, not all. When I tried your test with N=1, I did still get one leaked ref. I tried running with an extra gc.collect() at the end of each run, and that didn't help. I've verified that gc.collect() immediately after the running test_func() does reap a bunch of stuff. And I've verified that the sum of len(gc.getobjects()) for each run equals that of running it at the start and end of the whole program.

I'll let someone else who can look at the C code take over....

Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/

"usenet imitates usenet" --Darkhawk



More information about the Python-Dev mailing list