BEAM Internal data sizes

See also

Data sizes in the Erlang Efficiency Guide <http://erlang.org/doc/efficiency_guide/advanced.html>

Each boxed term has size described below plus one word for term value itself which you store somewhere else (be it on heap then you should count size for this term too, or in register/on stack - then it will not consume heap memory).

For specific bit positions and bit sizes please always refer to original beam sources, file: erl_term.h

Immediate

All immediate values have size of one Word.

They are: local pid, local port, small integer, atom, NIL (an empty list []) and catch (internal value). CP can also be considered an immediate although it is a special value which only appears on stack and never in registers or heap.

List

List value is a pointer to cons cell. Cons cell has size of two Words (one for head, and another for tail). Cons cell can link to next cons cell and so on, until tail becomes a non-list term (for improper lists) or NIL (for proper lists).

Size of a list is 1 Word (for a pointer) and also on the heap 2*num_cells Words.

Boxed

Boxed value is a pointer to the heap or some other area and always takes 1 Words. A Box always points to a memory block which starts with a Header (below) except during GC.