[erlang-questions] Relationship between erlang:memory/1, ets:info/2 and erlang:process_info/2

Anton Lebedevich <>
Sat Sep 22 10:18:35 CEST 2012


There could be even more inconsistensies between memory consumed by
erlang vm and statistics reported by memory().

top output
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
15863 root      20   0  721m 559m 3316 S    0 14.1   3:47.58 beam.smp

()1> memory().
[{total,103534784},
 {processes,18226104},
 {processes_used,14971560},
 {system,85308680},
 {atom,2247985},
 {atom_used,2227049},
 {binary,33598272},
 {code,25217445},
 {ets,1857024}]

Total in memory() output is about 100Mb but real memory usage of
erlang vm (R14B04) is ~600Mb

On Fri, Sep 21, 2012 at 8:50 PM, Simon MacMullen <> wrote:
> I'm trying to write something that will account for memory use on a RabbitMQ
> system. To do this I'm trying to match up the numbers I get out of
> erlang:memory(ets) and ets:info(T, memory), and erlang:memory(processes) and
> erlang:process_info/2.
>
> And it doesn't make a huge amount of sense to me. I don't expect things to
> match up perfectly, of course there will be some memory unaccounted for, but
> the ETS numbers in particular can be quite off:
>
> 1> erlang:memory(ets).
> 2120291872
>
> 2> lists:sum([ets:info(T, memory) || T <- ets:all()]) *
> erlang:system_info(wordsize).
> 1874292776
>
> So I have ~2GB of ETS memory, and ~230MB unaccounted for. Should I expect
> these to match up closer?
>
> And then...
>
> 3> erlang:memory(processes).
> 1519425156
>
> 4> lists:sum([element(2, process_info(P, memory)) || P <- processes()]).
> 1552852008
>
> So for processes there is less in total than if you add them all up. Is some
> memory shared? (Are we counting binaries and atoms in there as well?)
>
> Is there a way to get this sort of information in a more consistent manner?
>
> Cheers, Simon
>
> --
> Simon MacMullen
> RabbitMQ, VMware
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list