[erlang-questions] Preventing memory crashes
Mon Nov 21 20:03:54 CET 2016
The prometheus.erl project on github exposes that metric; you could look through the sources and see how they do it.
From: "Lyn Headley" <lheadley@REDACTED>
Sent: 11/21/2016 13:29
To: "erlang-questions" <erlang-questions@REDACTED>
Subject: [erlang-questions] Preventing memory crashes
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?
erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions