Why kernel kills processes that run out of memory instead of just failing memory allocation system calls?

perryh at pluto.rain.com perryh at pluto.rain.com
Thu May 21 08:21:50 UTC 2009


Nate Eldredge <neldredge at math.ucsd.edu> wrote:
> For instance, consider the following program.
<snip>
> this happens most of the time with fork() ...

It may be worthwhile to point out that one extremely common case is
the shell itself.  Even /bin/sh is large; csh (the default FreeBSD
shell) is quite a bit larger and bash larger yet.  The case of "big
program forks, and the child process execs a small program" arises
almost every time a shell command (other than a built-in) is executed.

> With overcommit, we pretend to give the child a writable private
> copy of the buffer, in hopes that it won't actually use more of it
> than we can fulfill with physical memory.

I am about 99% sure that the issue involves virtual memory, not
physical, at least in the fork/exec case.  The incidence of such
events under any particular system load scenario can be reduced or
eliminated simply by adding swap space.


More information about the freebsd-hackers mailing list