[Python-Dev] FYI: more clues re: tee+generator leak (original) (raw)
Phillip J. Eby pje at telecommunity.com
Mon Apr 17 19:09:14 CEST 2006
- Previous message: [Python-Dev] FYI: more clues re: tee+generator leak
- Next message: [Python-Dev] [ python-Patches-790710 ] breakpoint command lists in pdb
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 12:53 PM 4/17/2006 -0400, Phillip J. Eby wrote:
By the way, the above cycle will leak even if the generator is never iterated even once; it's quite simple to set up. I'm testing this using -R:: on testgenerators, and hacking on the fib function and friends.
Follow-up note: it's possible to create the same leak with this code:
l = []
a, b = tee(l)
l.append(b)
Which -R:: reports as leaking 4 references. If you "l.append(a)" instead of 'b', there is no leaking.
This showed that the problem was actually in the itertools module, as no generators are involved here.
After staring at tee_copy until my eyes bled, I accidentally scrolled such that tee_new was on the screen at the same time and notice that tee_copy was missing a call to PyObject_GC_Track();.
So then I fixed everything up and tried to check it in, to find that Thomas Wouters already found and fixed this yesterday.
The moral of the story? Always catch up on the Python-checkins list before trying to track down cycle leaks. :)
- Previous message: [Python-Dev] FYI: more clues re: tee+generator leak
- Next message: [Python-Dev] [ python-Patches-790710 ] breakpoint command lists in pdb
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]