Re: A true story of a crash.

Dancer (dancer@brisnet.org.au)
Wed, 19 Aug 1998 20:10:09 +1000


Michael Driscoll wrote:
>
> >Well, this overcommitment is fine in some cases, and not in others. A
> >kernel option that enables the no overcommit case would be nice for
> >some people.
> >
> >The argument FOR overcommitting memory is:
> >
> > Almost nobody check the malloc return values. And if they do, all
> > they do is bomb out with "out of memory". If you keep such a
> > process, it might even run to completion.
>
> There are people out there who don't check the return of malloc()? Yuck.
> I've *always* made it a habit to define my own xmalloc() which bombs with
> an error messages on malloc() return of NULL. If there are people who
> don't check the return of malloc(), then they get what's coming to then
> (unpredictable crashes in heavy load, for one).

What? Not checking the pointer returned from malloc()? Blasphemy, at the
very least(!).

I wrap almost all my malloc() calls up inside a subroutine that retries
failed memory allocations (sleep 1 second, try again. Fail after 30
tries, then return NULL). I figure if I can't get memory _right_now_ I
can wait a little while in case something terminates and releases some.
But I still check the return value, even after all that...

It's surprising what you can run out of, and when.

D

-
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.altern.org/andrebalsa/doc/lkml-faq.html