Erlang / Erlang Advanced Interview questions
Explain the internal working of Erlang's per-process garbage collector?
Each Erlang process has its own private heap, so garbage collection happens independently, one process at a time, rather than as one global stop-the-world pause across the whole node. When a process's heap fills up (typically triggered by a message arriving or an allocation), the BEAM runs a generational collector scoped to just that process.
flowchart LR
A[Process heap fills] --> B[Minor GC: copy live young data]
B --> C{Data survives multiple minor GCs?}
C -->|Yes| D[Promoted to old generation]
C -->|No| E[Reclaimed]
D --> F[Old generation collected less often]
Young, short-lived data gets collected frequently and cheaply (minor GC); data that survives several collections is promoted to an older generation that's swept less often, on the assumption that data still alive after multiple passes is likely to stay alive. Because each process's heap is small and private, these pauses are usually sub-millisecond and invisible to every other process on the node.
More Related questions...