[erlang-questions] Relationship between erlang:memory/1, ets:info/2 and erlang:process_info/2
Mon Sep 24 02:13:36 CEST 2012
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...
Rickard Green, Erlang/OTP, Ericsson AB
On Sep 24, 2012, at 1:40 AM, Rickard Green wrote:
> 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.
> Rickard Green, Erlang/OTP, Ericsson AB.
> On Sep 22, 2012, at 10:18 AM, Anton Lebedevich wrote:
>> 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
>> (node@REDACTED)1> memory().
>> 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 <simon@REDACTED> 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
>>> 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).
>>> 2> lists:sum([ets:info(T, memory) || T <- ets:all()]) *
>>> 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).
>>> 4> lists:sum([element(2, process_info(P, memory)) || P <- processes()]).
>>> 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-questions mailing list
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2290 bytes
Desc: not available
More information about the erlang-questions