memory used by Erlang VM

Gerhard Lazu gerhard@REDACTED
Fri Jan 31 21:14:58 CET 2020

I remember that battle with Erlang vs OS memory reporting well, it was such
a show. This captures my thinking from 2017: . This has more
There are a few other comments in that thread that you may find useful.

Erlang will either over-report or under-report the memory used.
erlang:memory(total) will very rarely match the physical RSS mapping, as
explained earlier by Jesper +
This detailed snapshot of Erlang memory allocators state shows this in the
clearest way that I am aware of:

As it stands, the Linux OOM takes action based on the RSS value. While from
an Erlang perspective it may seem OK to ask the OS for more memory, we've
had years of poor RabbitMQ experience when the Erlang VM process would get
killed by the Linux OOM because it was asking for memory that the system
didn't have available. This has more information:

Hope this helps, Gerhard.

On Fri, Jan 31, 2020 at 7:00 PM Jesper Louis Andersen <
jesper.louis.andersen@REDACTED> wrote:

> When you say /proc/pid, what are you looking at specifically in there? It
> is a bit different depending on which Unix you run on, so a simple
> example will help a lot.
> In particular, my early guess is going to be virtual memory vs physical
> RSS mapping. The former can be much higher than the latter. Especially in
> system such as Linux, which allow overcommitting memory.
> On Fri, Jan 31, 2020 at 7:22 PM Vyacheslav Levytskyy <
> v.levytskyy@REDACTED> wrote:
>> Hello,
>> I wonder why memory used by Erlang VM as reported by the kernel via the
>> /proc/pid differs from erlang:memory(total). In my current configuration
>> I observe realistic response from erlang:memory(total) and much lower
>> values from the /proc/pid.
>> I'm not surprised by the difference itself, but rather by the fact that
>> the /proc/pid gives unrealistically lower values -- I'm not 100% sure,
>> but it looks like RabbitMQ is using the /proc/pid approach by default,
>> proposing also recon_alloc:memory(allocated) and erlang:memory(total) as
>> available options of Erlang VM memory consumption calculation strategy.
>> Does anybody have insights of what and why is going on with those
>> calculations of memory used by Erlang VM? Is it possible to select one
>> strategy beforehand for my Erlang app, or I must measure on each new
>> configuration what looks more precise? Should I compare and change the
>> strategy during run-time, or after I selected a strategy once for my
>> configuration I can be sure that selected approach always better than
>> other two?
>> Thank you,
>> Vyacheslav
> --
> J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the erlang-questions mailing list