[Python-Dev] New leak

Tim Peters tim@zope.com
Tue, 31 Dec 2002 14:40:06 -0500


"A leak" in the datetime test turned out to be in the scaffolding that
prints the current refcount.  Here's a whittled test:

import sys
lastrc = 0
while True:
    thisrc = sys.gettotalrefcount()
    if 1:   # change 1 to 0 and there's no leak
        x = '*' * 10  # This leaks; ditto tuple times int, or list times int
    print >> sys.stderr, 'total refs:', thisrc, 'delta:', thisrc - lastrc
    lastrc = thisrc

Run that in a debug build, and it leaks one reference per loop trip.