[erlang-questions] Erlang get_memory_data

Gustav Simonsson <>
Fri Jul 13 11:22:03 CEST 2012


This is because the second value in the tuple returned by memsup:get_memory_data/0
does not represent "used" memory, it represents memory Linux has allocated for use
while no applications require it [1]. On my machine the function returns
{3169628160,3058540544,{<0.6.0>,213104}}
and 'free -m' reports I have 2.2 GB free for applications in the "-/+ buffers/cache"
row.

I looked briefly at the memsup source code, and it looks like the calculation that
decides whether a high watermark is set or not is based on the allocated value [2],
and not how much memory is in fact available for applications under Linux.

1. http://www.linuxatemyram.com/
2. https://github.com/erlang/otp/blob/maint/lib/os_mon/src/memsup.erl#L353

It looks like this needs to be revised for when memsup is running on Linux, so
it does not create false high memory alarms.

// Gustav Simonsson

Sent from my PC

----- Original Message -----
> From: "tsuraan" <>
> To: 
> Sent: Thursday, 12 July, 2012 8:09:13 PM
> Subject: [erlang-questions] Erlang get_memory_data
> 
> I have a Riak database that frequently gets memsup high watermark
> warnings and long_gc warnings, but really doesn't seem to be using
> much RAM.  When I run memsup:get_memory_data(), I get this output:
> 
> {4153327616,3424722944,{<0.7.0>,372152}}
> 
> Which I think indicates that erlang believes it's using ~3.5GB of RAM
> (or does it mean something completely different?).  If I run "grep
> ^Vm
> /proc/<pid>/status", I get this output:
> 
> VmPeak:   334560 kB
> VmSize:   270252 kB
> VmLck:         0 kB
> VmHWM:     33384 kB
> VmRSS:     33084 kB
> VmData:   225832 kB
> VmStk:       136 kB
> VmExe:      2028 kB
> VmLib:      6792 kB
> VmPTE:       232 kB
> VmSwap:        0 kB
> 
> So, Linux thinks Riak (beam) has never used more than ~350MB of RAM,
> and that it only has a ~30MB resident set.  pmap shows 90MB of
> writable anonymous pages, and a total of 262MB of mapped data.  Where
> is memsup's 3.5GB of RAM coming from?  Or am I way off on my ideas
> about what memsup is trying to tell me?
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
> 



More information about the erlang-questions mailing list