Blocking on allocation failure - WTF?
Posted Mar 10, 2011 14:42 UTC (Thu) by epa
In reply to: Blocking on allocation failure - WTF?
Parent article: Delaying the OOM killer
How would you pass that information?
By returning null, as is the documented interface for malloc().
Any memory access can fail due to lack of memory -- how do you handle that in userspace?
This is true, you can get errors on accessing memory that was previously 'allocated'. But that's not a reason for doing the wrong thing in this specific case. If it is quite certain that the memory isn't available, why not return that to the application using the documented interface? If the app wants to just sleep waiting for memory to become available, it can do so at its own choice.
to post comments)