New submission from Ian Henderson <i...@ianhenderson.org>:
To reproduce, copy the following code: ---- import gc gc.collect() objs = gc.get_objects() for obj in objs: try: if isinstance(obj, X): print(obj) except NameError: class X: pass def f(): x = X() raise Exception() f() ---- then open a Python REPL and paste repeatedly at the prompt. Each time the code runs, another copy of the local variable x is leaked. This was originally discovered while using PyTorch -- tensors leaked this way tend to exhaust GPU memory pretty quickly. Version Info: Python 3.9.7 (default, Sep 3 2021, 04:31:11) [Clang 12.0.5 (clang-1205.0.22.9)] on darwin ---------- components: Interpreter Core messages: 402144 nosy: ianh2 priority: normal severity: normal status: open title: python REPL leaks local variables when an exception is thrown type: resource usage versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue45241> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com