[erlang-questions] Preventing memory crashes
Mon Nov 21 19:56:05 CET 2016
You can monitor processes memory usage, and get signal, when it
is over certain threshold with erlang:system_monitor/2 or
just set limit and kill process with erlang:process_flag/2
Even set max heap size globally with erlang:system_flag/2 for
all newly spawned processes with max_heap_size
> On 21 Nov 2016, at 20:29, Lyn Headley <lheadley@REDACTED> wrote:
> I am looking to write a process that makes sure my node does not run
> out of memory and crash. What I would like is a function F that
> returns a number that represents the amount of memory my node is
> using. If that number gets above a threshold T, I will kill a process
> (carefully and safely, possibly after dumping its ets table to disk).
> After the process exits, I would immediately call the same function F
> and see whether the number it returns is now less than my threshold T.
> If not, kill another process, etc.
> Can I easily write this function F? Does the 'total' number from
> erlang:memory serve my needs here? In particular, will it go down
> immediately after I kill a process?
> Given a carefully chosen value for threshold T, and assuming no atoms
> or binaries are being allocated, (heap data and ets tables are the
> main drivers of memory use), will this strategy indeed prevent my node
> from crashing as long as I kill processes faster than they can grow?
> Other thoughts?
> erlang-questions mailing list
The single biggest problem in communication is the illusion that it has taken place. (George Bernard Shaw)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions