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

Simon MacMullen <>
Mon Sep 24 11:54:22 CEST 2012


On 24/09/12 00:34, Rickard Green wrote:
> The main structure of an ets table is erroneously accounted for
> twice in the erlang:memory(ets) case. :-(

Ah.

Well, that certainly explains a lot :-)

>> 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?)
>>
>
> This can happen when there are a lot of outstanding messages.

Not that I'm anything like as bothered about this case but for the
record my system was near-idle when I invoked those...

> The ets case above will be fixed.

That's cool, that was my main worry. Thank you.

> In the process case I haven't decided what to do, yet, but something
> will be done.

It's not too much of a bother for me, I just wanted to understand what 
was going on.

> erlang:memory/[0,1] use a very different (and cheaper) strategy than
> ets:info() and process_info(). The results will more or less always
> differ, and should since there are memory allocated that isn't for
> any specific process or ets-table in the erlang:memory() case.

Oh, sure. I am not trying to get things to add up precisely, but to let 
my users get a plausible idea of what the biggest blocks of memory are. 
I'm only concerned when the discrepancies are hundreds of megabytes.

Cheers, Simon

-- 
Simon MacMullen
RabbitMQ, VMware



More information about the erlang-questions mailing list