[Python-bugs-list] [ python-Bugs-682906 ] refcount leak in list +=

SourceForge.net noreply@sourceforge.net
Sat, 08 Feb 2003 08:13:40 -0800


Bugs item #682906, was opened at 2003-02-08 15:43
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=682906&group_id=5470

Category: None
Group: Python 2.3
>Status: Deleted
>Resolution: Invalid
Priority: 5
Submitted By: Walter Dörwald (doerwalter)
Assigned to: Nobody/Anonymous (nobody)
Summary: refcount leak in list +=

Initial Comment:
The following script leaks references:

import sys

c = 100
L = []

def test():
·    L2 = L
·    L2 += [1]*c

for i in xrange(10):
·    test()
·    print sys.gettotalrefcount()

The number of references leaked is exactly the value of 
c.

----------------------------------------------------------------------

>Comment By: Walter Dörwald (doerwalter)
Date: 2003-02-08 17:13

Message:
Logged In: YES 
user_id=89016

Argl, you're right. test() *does* modify the global variable. 
Deleting the bug report.

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-02-08 16:55

Message:
Logged In: YES 
user_id=33168

I don't think this is a leak.  The ref count increases
because there are <c> references to 1.  If you change the
loop like so:

for j in xrange(10):
    L = []
    for i in xrange(10):
        test()
    del L
    print sys.gettotalrefcount()

The refcount is constant.  I also attached the file with the
code above.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=682906&group_id=5470