[issue39143] Implementing sub-generation steps in the gc

Tim Peters report at bugs.python.org
Sat Dec 28 22:42:29 EST 2019


Tim Peters <tim at python.org> added the comment:

All right!  So, at a first look, "buffering" isn't an obvious disaster ;-)

I'm afraid nailing anything here is hard.  For example, I don't know what you did to "measure memory", but if you're using stats reported by the OS, that's fraught with dangers too.  Python's small-object allocator makes only weak attempts to return memory "to C", which in turn may or may not return memory to "the system".

One way to do better is to call `sys._debugmallocstats()` and stare at the output.  The "# bytes in allocated blocks" output line is an exact count of the number of bytes pymalloc is currently hanging on to for objects that have been allocated but not yet freed.  The point is that C - and the OS - have nothing to do with this value.  The downside:  objects > 512 bytes aren't included at all in this (pymalloc passes on requests for > 512 bytes to the system malloc(), and doesn't keep track of them).

Anyway, so far, so good!  Looks worth pursuing :-)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39143>
_______________________________________


More information about the Python-bugs-list mailing list