Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Relationship between erlang:memory/1, ets:info/2 and erlang:process_info/2
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Simon MacMullen  
View profile  
 More options Sep 21 2012, 12:51 pm
From: Simon MacMullen <si...@rabbitmq.com>
Date: Fri, 21 Sep 2012 17:50:53 +0100
Local: Fri, Sep 21 2012 12:50 pm
Subject: [erlang-questions] Relationship between erlang:memory/1, ets:info/2 and erlang:process_info/2
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
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Anton Lebedevich  
View profile  
 More options Sep 22 2012, 4:18 am
From: Anton Lebedevich <mab...@gmail.com>
Date: Sat, 22 Sep 2012 12:18:35 +0400
Local: Sat, Sep 22 2012 4:18 am
Subject: Re: [erlang-questions] Relationship between erlang:memory/1, ets:info/2 and erlang:process_info/2
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

(n...@127.0.0.1)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

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rickard Green  
View profile  
 More options Sep 23 2012, 7:35 pm
From: Rickard Green <rick...@erlang.org>
Date: Mon, 24 Sep 2012 01:34:45 +0200
Local: Sun, Sep 23 2012 7:34 pm
Subject: Re: [erlang-questions] Relationship between erlang:memory/1, ets:info/2 and erlang:process_info/2

On Sep 21, 2012, at 6: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?

The main structure of an ets table is erroneously accounted for twice in the erlang:memory(ets) case. :-(

> 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.

> Is there a way to get this sort of information in a more consistent manner?

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

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.

If you want to know memory used for all processes or all ets-tables use erlang:memory(). Much cheaper (both from the callers perspective, and especially from an overall performance perspective), as well as generally a more true value.

Summing up results of process_info(), or ets:info() will, of course, not give you a consistent snapshot of the memory usage at one point in time. Note that the same is true in the erlang:memory() case. The result is the sum of memory usage in different allocator instances that have been read at different (but close) points in time.

Regards,
Rickard Green, Erlang/OTP, Ericsson AB

> Cheers, Simon

> --
> Simon MacMullen
> RabbitMQ, VMware
> _______________________________________________
> erlang-questions mailing list
> erlang-questi...@erlang.org
> http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rickard Green  
View profile  
 More options Sep 23 2012, 7:40 pm
From: Rickard Green <rick...@erlang.org>
Date: Mon, 24 Sep 2012 01:40:14 +0200
Local: Sun, Sep 23 2012 7:40 pm
Subject: Re: [erlang-questions] Relationship between erlang:memory/1, ets:info/2 and erlang:process_info/2

erlang:memory() and 'top' reports information about two different things.

erlang:memory() reports the amount of memory that the runtime system has dynamically requested from the erts internal memory allocators. Memory allocators will satisfy these request by placing memory blocks in larger memory areas which we call carriers. There will both be memory used for allocator internal data structures as well as free unused memory in these carriers which is not accounted for by erlang:memory(), and shouldn't be accounted for by erlang:memory().

'top' reports all memory mapped by the emulator process. This includes the carriers used by the erts internal memory allocators, but also statically allocated memory, code of the emulator, etc...

When the emulator has grown large, memory carriers will normally (but not necessarily always) make up the major part of the memory reported by 'top' and other similar tools. I've attached a module, called memory, that can be used in order to sum up the sizes of all used carriers. The memory allocators may however keep unused carriers a while in order to try to reuse them. These unused carriers are not accounted for by the memory-module. Also note that this is a sum of sub results acquired at different (but close) points in time.

It should be possible to use the memory-module on R10B and upwards. Note that it is more or less untested. I've only smoke tested it on R15B02.

Regards,
Rickard Green, Erlang/OTP, Ericsson AB.

On Sep 22, 2012, at 10:18 AM, Anton Lebedevich wrote:

  memory.erl
2K Download

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rickard Green  
View profile  
 More options Sep 23 2012, 8:13 pm
From: Rickard Green <rick...@erlang.org>
Date: Mon, 24 Sep 2012 02:13:36 +0200
Local: Sun, Sep 23 2012 8:13 pm
Subject: Re: [erlang-questions] Relationship between erlang:memory/1, ets:info/2 and erlang:process_info/2

Untested code often do not work... This case was no different. I got a bug report almost immediately. Thanks Richard O'Keefe!

I've attached a new version that hopefully will work on R12 too, but I haven't tested it, so...

Regards,
Rickard Green, Erlang/OTP, Ericsson AB

On Sep 24, 2012, at 1:40 AM, Rickard Green wrote:

  memory.erl
2K Download

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon MacMullen  
View profile  
 More options Sep 24 2012, 5:54 am
From: Simon MacMullen <si...@rabbitmq.com>
Date: Mon, 24 Sep 2012 10:54:22 +0100
Local: Mon, Sep 24 2012 5:54 am
Subject: Re: [erlang-questions] Relationship between erlang:memory/1, ets:info/2 and erlang:process_info/2
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
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »