Tim Peters <t...@python.org> added the comment:

I see no evidence of a bug here. To the contrary, the output proves that 
__del__ methods are getting called all along. And if garbage weren't being 
collected, after allocating a million objects each with its own megabyte string 
object, memory use at the end would be a terabyte, not a comparatively measly 
;-) gigabyte

Note that Python's cyclic gc is NOT asynchronous. It only runs when you call it 
directly, or when an internal count of allocations exceeds an internal count of 
deallocations. When your loop ends, your output shows that 940 A and B objects 
remain to be collected, spread across some number of the gc's "generations". 
That's where your gigabyte lives (about a thousand A objects each with its own 
megabyte of string data). It will remain in use until gc is forced to run 
again. But 99.9% of the A objects have already been collected.

----------
nosy: +tim.peters

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41389>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to