A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-November/094304.html below:

[Python-Dev] new unbounded memory leak in exception handling?

[Python-Dev] new unbounded memory leak in exception handling? [Python-Dev] new unbounded memory leak in exception handling?Greg Hewgill greg at hewgill.com
Tue Nov 17 11:31:07 CET 2009
I've constructed an example program that does not leak memory in Python
2.x, but causes unbounded memory allocation in Python 3.1. Here is the
code:

import gc
import sys

class E(Exception):
    def __init__(self, fn):
        self.fn = fn
    def call(self):
        self.fn()

def f():
    raise E(f)

a = E(f)
while True:
    print(len(gc.get_objects()))
    try:
        a.call()
    except E:
        # get exception value in a python2/3 portable way
        a = sys.exc_info()[1]

Every time through the loop, the length of gc.get_objects() increases
by 7 under Python 3.1. I believe this is a regression error, since
Python 2.x does not exhibit the same behaviour.

Can anybody confirm this?

Greg Hewgill
http://hewgill.com
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4