[Python-ideas] More details in MemoryError

Chris Angelico rosuav at gmail.com
Tue Jan 22 14:04:15 CET 2013


On Tue, Jan 22, 2013 at 11:42 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> Something like this could be used to decide whether or not to flush
> unimportant in-memory caches, compact data structures, etc., or just
> give up and exit.

That's a nice idea, but unless the requested allocation was fairly
large, there's a good chance you don't have room to allocate anything
more. That may make it a bit tricky to do a compaction operation. But
if there's some sort of "automatically freeable memory" (simple
example: exception-triggered stack unwinding results in a whole bunch
of locals disappearing), and you can stay within that, then you might
be able to recover. Would require some tightrope-walking in the
exception handler, but ought to be possible.

ChrisA



More information about the Python-ideas mailing list