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

Tony Rogvall tony@REDACTED
Mon Nov 9 09:45:10 CET 2009

Interesting discussion!

I have been working on a resource system for Erlang for nearly two  
years now.
I have a working (tm) prototype where you can set resource limits like
max_processes/max_ports/max_memory/max_time/max_reductions ...
The limits are passed with spawn_opt and are inherited by the  
processes spawned.
This means that if you spawn_opt(M,F,A[{max_memory, 1024*1024}]) the  
will be able to use 1M words for it self and it's "subprocesses". This  
also means
that the spawner will get 1M less to use (as designed right now). If a  
resource limit
is reached the process crash with system_limt reason.

There are still some details to work out before a release, but I will  
try to get it ready before
end of this year.


On 9 nov 2009, at 09.16, Robert Virding wrote:

> No.
> There is a major difference between handling OOM in an OS and in the  
> 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
> 2009/11/9 Max Lapshin <max.lapshin@REDACTED>
>> Yes, there are techniques to write watchdogs, but my question was: is
>> it possible to prevent Erlang VM from crash?
>> ________________________________________________________________
>> erlang-questions mailing list. See http://www.erlang.org/faq.html
>> erlang-questions (at) erlang.org

More information about the erlang-questions mailing list