[Python-ideas] Preventing out of memory conditions

Random832 random832 at fastmail.us
Tue Jan 1 04:28:43 CET 2013


On 12/31/2012 7:11 PM, Ben Hoyt wrote:
> Interesting idea, though I don't think it's something that should be a 
> Python language extension. For instance, iOS (typically more 
> resource-constrained) sends the application signals when system memory 
> is getting low so it can free stuff -- this is done at the OS level. 
> And I think that's the right place, because this will almost certainly 
> be setup- and system-dependent. For instance, it would depend hugely 
> on whether there's a virtual memory manager, and how it's configured.
>
> I'd say your best bet is to write a little library that does the 
> appropriate thing for your needs (your system or setup). Say starts a 
> thread that checks the system's free memory every so often and sends 
> your application a signal/callback saying "we're getting low, free 
> some of your caches". It could even send a "level flag" to your 
> callback saying "fairly low", "very low", or "critically low" -- I 
> think iOS does this.

I'm concerned that a program that does this will end up as the loser in 
this scenario:

http://blogs.msdn.com/b/oldnewthing/archive/2012/01/18/10257834.aspx

(tl;dr, two programs each having a different idea of how much free 
memory the system should have results in an "unfair" total allocation of 
memory)

I think it's possibly important to avoid using the system's free memory 
as an input to any such system.



More information about the Python-ideas mailing list