malloc does not return null when out of memory

Don Lewis truckman at FreeBSD.org
Wed Jul 23 18:52:32 PDT 2003


On 23 Jul, Brooks Davis wrote:
> On Thu, Jul 24, 2003 at 12:36:54AM +0200, Matthias Buelow wrote:
>> Barney Wolff writes:
>> 
>> >One might argue that this is a config error, and ulimit should be used
>> >to cut the address space to below actually available memory.
>> 
>> Wasn't there a sysctl flag to enable/disable overcommitting?
>> I think I remember something but I can't find it; it might
>> not have been on FreeBSD.
> 
> No there isn't.  Overcommit is a fundamental design feature of the BSD
> VM.  If you don't like it, find an OS that doesn't do it.  The only one
> I can think of off the top of my head in Irix where I've found it to be
> a serious pain in the ass.

I think it's a pain in the ass when swap runs out and the kernel decides
to kill off my X11 server to fix the problem.  In addition to losing
everything I'm working on, it also hoses the console.  The only reason
that I can avoid having to hit the reset switch and risking further
system damage is that I have another machine that I can ssh in from to
do a clean shutdown.

I used SunOS 4.x, which did not overcommit, for many years.  Its typical
failure mode when swap was exhausted is that large processes would get a
error when they attempted to fork() and large memory alloction requests
would fail.  Everything else would generally keep working because
smaller memory allocation requests would still succeed. This usually
gave me enough time to take corrective action (generally by cleaning up
junk files in /tmp which was a tmpfs mount).


More information about the freebsd-stable mailing list