[erlang-questions] Max heap size

Lukas Larsson lukas@REDACTED
Wed Apr 27 15:12:39 CEST 2016

On Wed, Apr 27, 2016 at 2:23 PM, Valentin Micic <v@REDACTED>
> Are you saying that a process will be terminated regardless of how much
> actual memory we have within a system as a whole?


> 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?

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.

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.

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?

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.

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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160427/9b2c55bd/attachment.htm>

More information about the erlang-questions mailing list