Antoine Pitrou added the comment:
> As a fast approximation the default implementation of the __sizeof__ method
> can be used
This doesn't handle further resizing of containers, though.
--
___
Python tracker
Serhiy Storchaka added the comment:
There is an existing protocol for estimating the size of allocated memory.
__sizeof__. Python API sys.getsizeof() and C API _PySys_GetSizeOf(). But it is
too heavy for using in GC.
As a fast approximation the default implementation of the __sizeof__ method
Antoine Pitrou added the comment:
Yes, this is a potentially annoying limitation of the current scheme.
Note that it's not obvious how to proceed for resizable objects such as lists.
Should the list inform the GC of every internal resizing? May a list resize
trigger a GC run?
Also, a small
New submission from Armin Rigo:
The cyclic GC uses a simple and somewhat naive policy to know when it must run.
It is based on counting "+1" for every call to _PyObject_GC_Alloc(). Explicit
calls to PyObject_GC_Del() are counted as "-1". The cyclic GC will only be
executed after the count