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

Simon MacMullen simon@REDACTED
Fri Sep 21 18:50:53 CEST 2012


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



More information about the erlang-questions mailing list