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

Björn-Egil Dahlberg wallentin.dahlberg@REDACTED
Fri Feb 8 04:27:54 CET 2013


2013/2/8 <ok@REDACTED>

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

Btw, If its just the matter of memory then there exists erts_debug:size/1
and erts_debug:flat_size/1 (calculates number of words):

Eshell V5.9  (abort with ^G)
1> A = {1,2,3}.
{1,2,3}
2> B = [A|A].
[{1,2,3}|{1,2,3}]
3> erts_debug:size(B).
6
4> erts_debug:flat_size(B).
10



>
> 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
> memory.
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130208/f78fbb54/attachment.htm>


More information about the erlang-questions mailing list