[erlang-questions] Preventing memory crashes

Lyn Headley lheadley@REDACTED
Mon Nov 21 19:29:48 CET 2016


Erlangers,

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?

-Lyn



More information about the erlang-questions mailing list