<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><div><div style="font-family: Calibri,sans-serif; font-size: 11pt;">The prometheus.erl project on github exposes that metric; you could look through the sources and see how they do it.</div></div><div dir="ltr"><hr><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">From: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:lheadley@kcptech.com">Lyn Headley</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Sent: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;">‎11/‎21/‎2016 13:29</span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">To: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:erlang-questions@erlang.org">erlang-questions</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Subject: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;">[erlang-questions] Preventing memory crashes</span><br><br></div>Erlangers,<br><br>I am looking to write a process that makes sure my node does not run<br>out of memory and crash. What I would like is a function F that<br>returns a number that represents the amount of memory my node is<br>using. If that number gets above a threshold T, I will kill a process<br>(carefully and safely, possibly after dumping its ets table to disk).<br>After the process exits, I would immediately call the same function F<br>and see whether the number it returns is now less than my threshold T.<br>If not, kill another process, etc.<br><br>Can I easily write this function F? Does the 'total' number from<br>erlang:memory serve my needs here? In particular, will it go down<br>immediately after I kill a process?<br><br>Given a carefully chosen value for threshold T, and assuming no atoms<br>or binaries are being allocated, (heap data and ets tables are the<br>main drivers of memory use), will this strategy indeed prevent my node<br>from crashing as long as I kill processes faster than they can grow?<br><br>Other thoughts?<br><br>-Lyn<br>_______________________________________________<br>erlang-questions mailing list<br>erlang-questions@erlang.org<br>http://erlang.org/mailman/listinfo/erlang-questions<br></body></html>