[erlang-questions] Tuple memory size

Mikael Pettersson <>
Fri Feb 20 20:31:55 CET 2009


tsuraan writes:
 > In memory, is a tuple an array of pointers, or are the tuple and its
 > contents actually stored contiguously?

A tuple is an array of "term handles", which in turn can either
contain pointers to terms allocated elsewhere in memory (boxed),
or contain certain smallish terms (mainly small integers, atoms,
and the empty list) directly (immediates). The low bits of the
handle determine its interpretation.

 >  In other words, if you have a
 > tuple that contains dozens of other tuples that contain integers, will
 > changing an element of the top-level tuple require a deep copy, or
 > will it just make a new tuple that points at mostly the same objects
 > as the old one?

The latter.



More information about the erlang-questions mailing list