This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author twouters
Recipients
Date 2006-03-27.20:59:02
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=34209

Hmm. Well, adding PyObject_GC_Track() makes GC work right. I
don't know why, since the rest of itertools doesn't use
PyObject_GC_Track, but it now fixes refleaks that involve
just itertools, like:

def leak():
    class gen:
        def __iter__(self):
            return self
        def next(self):
            return self.item
    g = gen()
    head, tail = tee(g)
    g.item = head

This example leaked without tee doing GC (and without
PyObject_GC_Track), but doesn't leak with proper GC.
However! test_generators still leaks, and so does this
example (which doesn't use itertools):

def leak():
    def gen():
        while True:
            yield g
    g = gen()
    g.next()

I suspect this leak was introduced after I submitted this
patch, which explains why this patch suddenly stopped
working ;) Since adding GC still fixes reference-cycles, I
will check in this patch while I hunt for the other leak.
History
Date User Action Args
2007-08-23 15:46:42adminlinkissue1444398 messages
2007-08-23 15:46:42admincreate