[erlang-questions] [eeps] New EEP: setrlimit(2) analogue for Erlang

Fri Feb 8 04:04:38 CET 2013

> An idea which seems like it should be included in this EEP, is simply a
> function to determine how much real memory is consumed by an erlang
> variable.

Given a language with immutable data structures and free sharing,
I am having a hard time trying to think what this might mean.
Consider as one of the *easy* cases

    L0 = [],
    L1 = [L0|L0],
    L99 = [L98|L98]

The amount of memory it really uses is just 99 cons cells,
presumably 198 words.  The amount that will be calculated
by a recursive sizer is about 2^99 (approximately).

There are at least the following notions:
 - size in external representation
 - amount copied when sent to a local PID
 - amount found by a recursive walker
 - amount used taking internal cycles into account
 - fair share considering all references in the current PID
 - fair share including references to binaries from other PIDs.

It seems to me that there is one thing that _could_ be done
but would be a fair bit of work, and that's allocation
profiling.  Arrange to generate different BEAM code which
records each (amount of memory, source location where
allocation happens) so that you can run a test case and see
which expressions are responsible for allocating how much

More information about the erlang-questions mailing list