Raymond Hettinger <[email protected]> added the comment:
Whats going on is that the implementation tracks blocks of 56 references at a
time, freeing entire blocks at time. So the memory release does occur
periodically, but not as aggressively as it could. This code shows what is
going on:
# Show the timing of when objects are decreffed
from itertools import tee
class Notify:
def __init__(self, x):
self.x = x
def __del__(self):
print('<Clearing: %r>' % self.x)
def __repr__(self):
return 'Notify(%r)' % self.x
it = map(Notify, range(100))
p, q = tee(it)
for i in range(100):
next(p)
next(q)
print(i)
print('Deleting it')
del it
print('Deleting p')
del p
print('Deleting q')
del q
I'll look to see if the objects can be freed sooner without doing major brain
surgery to the existing code.
----------
assignee: -> rhettinger
nosy: +rhettinger
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue40047>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com