lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sep 11, 2014, at 12:38 PM, Sean Conner <sean@conman.org> wrote:

> 
>  How would *you* handle ENOMEM?  
> 
>  I wrote a big on this a few years ago:
> 
> 	http://boston.conman.org/2009/12/01.2
> 

imho ENOMEM (or getting NULL from malloc()) are pretty much an app panic. In our major apps we shim the malloc() family and then pre-allocate a block of memory. If the shim detects a malloc() failure it releases this block, puts the app in “clean but fast shutdown” mode, and then retries the malloc(). Even this is only really a last-ditch attempt to do a cleanup before we die.

—Tim