New submission from Cliff Cordeiro :
This class is not collected by the gc without a custom __del__ method to del or
assign None to self.fn:
import gc
class Leak:
def __init__(self):
self.fn = self.x
def x(self):
pass
gc.set_debug(gc.DEBUG_SAVEALL)
l = Leak()
del l
gc.collect()
for item in gc.garbage:
print(item)
--
components: Interpreter Core
messages: 399165
nosy: cliff.cordeiro
priority: normal
severity: normal
status: open
title: class member varibles assigned member functions create a circular
reference
type: resource usage
versions: Python 3.8
___
Python tracker
<https://bugs.python.org/issue44857>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com