[erlang-questions] simple question about list memory consumption
Fri Jul 6 16:00:22 CEST 2012
Francesco Mazzoli wrote:
> At Fri, 6 Jul 2012 15:08:30 +0200,
> Sverker Eriksson wrote:
>> Small enough integers (28/60 bit signed integers) *are* stored as immediates
>> in the list cells.
> How can this be, without some kind of tagging, since Erlang list are
> heterogeneous - which would increase memory overhead anyway?
> In other words, if I have [foo, 1, bar], if the 1 is unboxed, how does Erlang
> know it is an integer?
It is done with tagging.
The two least significant bits are used for tagging as they are always 0
for a pointer to word aligned data.
More information about the erlang-questions