Blocking on allocation failure - WTF?
Posted Mar 10, 2011 14:39 UTC (Thu) by
epa (subscriber, #39769)
In reply to:
Blocking on allocation failure - WTF? by alonz
Parent article:
Delaying the OOM killer
What you miss is that in modern Linux, malloc() practically never fails.
Right, but here is an instance where it does fail to allocate memory. It is known that the memory is not available right now (although of course it might become available at some point in the future). The malloc() API has provision for letting that be known to the application, by returning null. If the application wants to just hang until memory becomes available, that can easily be implemented in user-space (perhaps at the cost of a little busy-waiting or sleeping); but on the other hand if the application would like to find out when no more memory is available and do something, it's impossible to implement that on top of a malloc() interface that just blocks indefinitely.
(
Log in to post comments)