[issue44553] types.Union should support GC
Ken Jin
report at bugs.python.org
Fri Jul 2 10:53:38 EDT 2021
New submission from Ken Jin <kenjin4096 at gmail.com>:
types.Union objects can contain reference cycles, therefore causing memory leaks.
E.g.::
```
import sys, gc
from typing import TypeVar
gc.collect()
for _ in range(10):
sys.gettotalrefcount()
T = TypeVar('T')
U = int | list[T]
T.blah = U
del T
del U
gc.collect()
```
Result:
84470
0
84488
0
84504
0
84520
0
84536
0
I'm sending a small PR soon to implement GC methods to fix this.
----------
messages: 396867
nosy: gvanrossum, kj
priority: normal
severity: normal
status: open
title: types.Union should support GC
versions: Python 3.10, Python 3.11
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44553>
_______________________________________
More information about the Python-bugs-list
mailing list