[New-bugs-announce] [issue9366] Reference leak for local new style class

Kay Hayen report at bugs.python.org
Sat Jul 24 11:46:41 CEST 2010

New submission from Kay Hayen <kayhayen at gmx.de>:


I have created tests that check the reference counting and found that the following simple function leaks references in CPython:

def simpleFunction39():
   class Parent( object ):

I have attached a test that needs to be run with python-dbg and checks the total reference count for many language constructs. Sometimes a warmup can be useful, if CPython caches something, but it doesn't help in this case. Removing object or replacing it with an old style class helps.

I think I saw that 3 references of object leak, and a total of ca. 20 for each call to the function. I suspect a memory leak too.

Use the attached file for reproduction of the problem.

components: Interpreter Core
files: Referencing.py
messages: 111433
nosy: kayhayen
priority: normal
severity: normal
status: open
title: Reference leak for local new style class
type: resource usage
versions: Python 2.6
Added file: http://bugs.python.org/file18173/Referencing.py

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list