<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Apr 27, 2016 at 2:23 PM, Valentin Micic <span dir="ltr"><<a href="mailto:v@pharos-avantgard.com" target="_blank">v@pharos-avantgard.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Are you saying that a process will be terminated regardless of how much actual memory we have within a system as a whole?</div></div></blockquote><div><br></div><div>yes</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div></div><div>Well, how useful would it be to kill a mission critical process just because it is using slightly more memory that we have originally envisaged?</div></div></blockquote><div><br></div><div>That would depend on the application. If you have a process that cannot die, then you should not put a max_heap_size on it.</div><div><br></div><div>The limit should be a guard against extreme memory usage growth, not be a something you put very close to your normal maximum. If you want to use this limit I suggest first running it with kill => false and see what heap sizes gets reported to the error_logger  and then set the max_heap_size to an appropriately high value.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Wouldn't it be more suitable to have a process flag that would instruct the VM to send a specific message to the process once particular heap size have been reached and let process decide what to do about it?<br></div></div></blockquote><div><br></div><div>You can build this using erlang:system_monitor(self(), [{large_heap, Sz}]) if you want to have it, or you could hook into the error_logger and react to the messages sent by max_heap_size.</div><div><br></div><div>Part of the point of the max_heap_size is that the process should be killed without having to do the potentially expensive garbage collection that is about to come, which is only achievable through an untrappable exit signal.</div><div><br></div><div>Lukas</div></div></div></div>