<br><div><span class="gmail_quote">On 3/5/06, <b class="gmail_sendername">Neal Norwitz</b> &lt;<a href="mailto:neal@metaslash.com">neal@metaslash.com</a>&gt; wrote:</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
test_generators leaked [255, 255, 255] references</blockquote></div><br>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.)
<br><br>The last leak is somewhere in the coroutines_tests doctest, but I haven't taken the time to figure out where, exactly.<br clear="all"><br>-- <br>Thomas Wouters &lt;<a href="mailto:thomas@python.org">thomas@python.org
</a>&gt;<br><br>Hi! I'm a .signature virus! copy me into your .signature file to help me spread!