[Python-Dev] funny leak

Neal Norwitz neal@metaslash.com
Mon, 24 Mar 2003 09:00:23 -0500


On Mon, Mar 24, 2003 at 07:51:00AM -0600, Jeff Epler wrote:
> On Mon, Mar 24, 2003 at 08:43:16AM -0500, Neal Norwitz wrote:
> > One ref may be leaked the first time gc.collect() is called with
> > garbage (23150 -> 23151).  But after that, no more refs are leaked
> > (ref count stays at 23151).
> 
> If that's true, then running the 'def' block repeatedly will leak
> references, right?  I think from Christian's original message this is
> what he meant, but I'm not sure.

I misread the original message.  Running the 'def' block does indeed
leak a reference and collect() has no effect.  Similarly:

        [23154 refs]
        >>> def conjoin(gs):
        ...     def gen():
        ...         gs      # unbreakable cycle
        ...         gen     # unless one is commented out
        ... 
        [23194 refs]
        >>> del conjoin
        [23155 refs]

Neal