Re: Out Of Memory in v. 2.1

Stefan Monnier (monnier+lists/linux/kernel/news/@TEQUILA.SYSTEMSZ.CS.YALE.EDU)
07 Oct 1998 10:26:58 -0400


>>>>> "Jeff" == Jeff Garzik <jgarzik@pobox.com> writes:
> Sanity check time. :) Returning NULL when memory is unavailable is a
> very basic premise, let's not to break something that has been working
> for more than 20 years.

I actually disagree; malloc should *never* return NULL:
- as you mentionned, even if it returns non-NULL, the process might end up
killed later because of over-commitment, so returning NULL is only sometimes
useful.
- most programs don't know what to do when malloc return NULL, so they end up
killing themselves: why bother ask the process to kill itself ?

i.e. it's a waste of the programmer's time.

Stefan

PS: the only improvement over killing some process would be to send a
SIGOOM first, in order to give the process a chance to clean up before
exiting. But this cleanup is likely to fail because in OOM situations,
tons of things cannot be done. So you'd want to keep around a few extra
KBs (similar to the reserved-blocks of ufs).

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/