Erlang / Erlang Advanced Interview questions
Why does Erlang use generational (per-process) garbage collection instead of a single global GC?
A single global collector would need to pause every process on the node at once to safely scan and compact memory, which directly conflicts with Erlang's goal of soft real-time responsiveness — a telecom switch or messaging backend can't tolerate a multi-hundred-millisecond global pause just because one process allocated too much data.
By giving each process its own private heap, the BEAM can collect one process without touching anyone else's memory or execution, keeping collection pauses small, local, and predictable. The generational split (young vs old data) further reduces work per collection, since most allocations in typical Erlang code are short-lived (temporary variables inside a function call), so scanning only the young generation most of the time is far cheaper than rescanning everything.
The tradeoff is that shared, cross-process references aren't possible the way they are in a shared-heap runtime — which is exactly why message passing between processes has to copy data rather than share a pointer.
More Related questions...