[erlang-questions] Why Beam.smp crashes when memory is over?

Kenneth Lundin kenneth.lundin@REDACTED
Mon Nov 9 10:53:10 CET 2009

On Mon, Nov 9, 2009 at 9:16 AM, Robert Virding <rvirding@REDACTED> wrote:
> No.
> There is a major difference between handling OOM in an OS and in the BEAM.
> In an OS it usually at a per process level that memory runs out so it is
> easy to decide which process to kill so that the OS can continue. In the
> BEAM, however, it is the VM as a whole which has run out of memory not a
> specific, it is. therefore, much more difficult to work out which process is
> the culprit and to decide what to do. For example it might be that the
> process which causes the OOM is not the actual problem process, it might
> just the last straw. Or the actual cause may that the whole app might be
> generating large binaries too quickly. Or it might be that the whole app is
> spawning to many processes without any one process being the cause. Or ...
> In all these cases killing the process which triggered the OOM would be the
> Wrong Thing. We found that it was difficult to work out a reasonable
> strategy to handle the actual cause so we decided not handle it.
> "Don't catch an error which you can't handle" as the bard put it.
> Robert

We have discussed this many times and have always come to the same
conclusion as Robert expains above, that we can't know the right thing
to do so we just do nothing and terminate the VM.

What we could do is to make it easier for the user to prevent OOM
situations and also to
let him take the decision when it occurs or rather before it occurs.

One way would be to let the user set a memory quota on a process with
options at spawn time. When the process reaches it quota it can be
automatically killed or the user can
be notified in some way and take actions.

We have also thought about ways for the user to monitor memory consumption and
by this taking actions before the VM runs out of memory.

/Kenneth, Erlang/OTP Ericsson

More information about the erlang-questions mailing list