[erlang-questions] Erlang's garbage collector

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Thu Aug 22 23:04:36 CEST 2013

On Thu, Aug 22, 2013 at 4:35 PM, Yves S. Garret

> Am I understanding this correctly?  You have two heaps and if a piece of
> memory keeps getting
> referenced, it gets moved into the "old" heap and the "new" heap's memory
> gets freed up a little,
> yes?

Well the heap is divided in two regions, old and young. New data is
allocated on the young heap. When it fills, the young heap is garbage
collected. Data which is dead is removed and data which is still live
survives on the young heap. When it has survived enough times (3) then it
is promoted to the old heap.

The reason for this scheme is that you keep the young heap small and
collect it often. Collection is faster in a small heap. Also, since most
objects tend to be used only once at most, they are usually dead when the
young heap collects. Objects which survive are usually long lived, so they
get promoted into the old heap. It is then collected more rarely.

The view here is simplified, but it might do.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130822/e7644c6b/attachment.htm>

More information about the erlang-questions mailing list