[Python-ideas] Preventing out of memory conditions

Jim Jewett jimjjewett at gmail.com
Thu Jan 3 03:13:47 CET 2013


On 12/31/12, Max Moroz <maxmoroz at gmail.com> wrote:
> Sometimes, I have the flexibility to reduce the memory used by my
> program (e.g., by destroying large cached objects, etc.). It would be
> great if I could ask Python interpreter to notify me when memory is
> running out, so I can take such actions.

Agreed, provided the overhead isn't too high.

Depending on how accurately and precisely you need to track the memory
usage, it might be enough to replace Objects/obmalloc.c new_arena with
a wrapper that calls your callback before (maybe) allocating a new
arena.

-jJ



More information about the Python-ideas mailing list