[Python-Dev] [Python-checkins] Python Regression Test Failures refleak (1)

Thomas Wouters thomas at python.org
Mon Mar 6 02:45:51 CET 2006

On 3/5/06, Neal Norwitz <neal at metaslash.com> wrote:

> test_generators leaked [255, 255, 255] references

254 of those 255 leaks seem to be caused by the two recursive-generator
examples at the bottom of the fun_tests doctest: fib() and the last m235()
implementation. The recursiveness isn't in the generators themselves, but
rather in the use of their own return values through a nested scope -- the
cell objects for those values hold tee-iterators which hold (through a
tee-dataobject) a reference to the generator. It doesn't look like
tee-objects participate in GC, so there's no way to break the cycle. I added
a quick 'close' implementation to itertools.tee, which just calls the
'close' method of whatever iterator it is tee'ing, and that does solve the
issue. Considering the fairly convoluted use of generators, I guess the
latter solution is acceptable (although it would be nice if tee objects did
do GC, at least enough so to let the GC do its work. I haven't looked at
howmuch effort that would take.)

The last leak is somewhere in the coroutines_tests doctest, but I haven't
taken the time to figure out where, exactly.

Thomas Wouters <thomas at python.org>

Hi! I'm a .signature virus! copy me into your .signature file to help me
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20060306/d3b2f449/attachment.html 

More information about the Python-Dev mailing list