Re: Out Of Memory in v. 2.1

Jeff Garzik (jgarzik@pobox.com)
Wed, 7 Oct 1998 14:25:28 -0400 (EDT)


Stefan Monnier wrote:
> >>>>> "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:

Please see malloc(3). The man page disagrees with you. :)

malloc() has returned NULL for OOM situations for over two decades.
What is your justification for breaking that behavior?

> - - 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.

Returning NULL is _always_ useful, when NULL can be returned.

> - - 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 ?

Because your "most programs" are not mission-critical. I damn sure want
my Oracle database notified when it cannot get any more memory.

All my production programs studiously check malloc(), and they handle
OOM conditions quite gracefully under Solaris.

Until OOM situations can be handled as "gracefully" as they are handled
under Solaris, Linux cannot be considered a production OS.

Jeff

-
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/