Repository navigation
COMPAT: notify garbage collector when memory is allocated - #8907
Conversation
|
Thanks @mattip . |
|
Did you really mean I'm pretty sure this isn't the only place we allocate memory... (At the least there has to be both |
|
@njsmith The code as it stands is correct but admittedly misleading, the functions are aliases for one another. Explaination: PyPy prevents mixing CPython headers with the PyPy runtime by add an extra Py to the name exported in the shared object. For instance, I assumed all ndarray data allocations are done with Should |
|
how does this work exactly? When the GC runs it just sets memory pressure back to zero? |
|
The first answer is correct. Any GC tracked allocation (all PyPy internal allocations are tracked) is added to a counter, when the counter is large enough a GC collection cycle is triggered. The counter is reset after each cycle. Adding memory pressure simply increments the counter. |
PyPy's garbage collector (GC) starts a cycle based on an algorithm that takes into account allocated memory. It must be told about allocations outside of python. This patch triggers more frequent GC cycles when ndarrays are allocated in a tight loop, which while not efficient will now at least run to completion without allocating all the free memory in the system.