Prev Next

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.

What responsiveness goal drives Erlang's per-process GC design?
What capability do you give up in exchange for isolated per-process heaps?

Invest now in Acorns!!! 🚀 Join Acorns and get your $5 bonus!
Acorns Logo

Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!

Earn passively and while sleeping

Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.

Robinhood Logo

Invest now!!! Get Free equity stock (US, UK only)!

Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.

The Robinhood app makes it easy to trade stocks, crypto and more.


Webull Logo

Webull! Receive free stock by signing up using the link: Webull signup.

More Related questions...

What is the difference between linking and monitoring a process? Why would you choose monitor over link for a client process? What is a dirty scheduler and when should a NIF use one? Explain the internal working of Erlang's per-process garbage collector? Why does Erlang use generational (per-process) garbage collection instead of a single global GC? What is EPMD and what role does it play in distributed Erlang? Why do distributed Erlang nodes require a shared cookie? Explain the internal working of the Erlang distribution handshake between two nodes? What is the two-version code loading rule and what happens when a third version is loaded? Explain the internal working of code:purge/1 and code:soft_purge/1? What is a gen_event and when would you choose it over gen_server? What is the difference between error, exit, and throw in Erlang? Why is exit/1 different from exit/2? What is an OTP application (.app file) and how does it differ from a single module? Explain the execution flow of application:start/1 and its dependency resolution? What is a release in OTP and how does it differ from an application? Explain the internal working of a relup-based hot upgrade? What is the code_change/3 callback used for in gen_server? How does the global module handle process name registration across a cluster? Why can global name registration cause a network partition ("split brain") problem? What is the pg (process groups) module used for? What are Erlang maps and how do they differ from records? When should you choose a map over a record for structured data? What is the difference between ets:match, ets:select, and ets:foldl? How can you use match specifications to filter ETS data efficiently? What do the write_concurrency and read_concurrency ETS options optimize for? How can you optimize binary pattern matching for parsing variable-length network protocols? Why is copying a large list between processes more expensive than copying a large binary? What is tail call optimization in Erlang and why does it matter for long-running loops? How do you write a properly tail-recursive accumulator-based function? Explain the internal working of selective receive and why message order in the queue matters? What is erlang:process_flag(priority,...) used for? Why should high-priority processes be used sparingly in Erlang? What is rpc:call/4 and how does it work across distributed nodes? What is the difference between rpc:call and simply sending a message to a remote PID? How does erlang:send/3 with the nosuspend option change message-sending behavior? What is Dialyzer and how does success typing differ from static typing? Why doesn't Dialyzer catch every type error the way a traditional type checker would? How do you define and use a custom behavior with the -callback attribute? What is the difference between a behavior callback module and a plain library module? Explain the internal working of exception propagation through nested try/catch blocks? When should you use throw instead of returning an {error, Reason} tuple? How do you troubleshoot a memory leak caused by large binaries not being garbage collected? What is the significance of the binary reference count and off-heap binary garbage collection? Why is the Erlang distribution protocol not encrypted by default, and how can you secure inter-node traffic? Why is Mnesia's two-phase commit necessary for distributed transactions? How do you troubleshoot slow ETS lookups on a heavily-used table? Why might increasing the number of BEAM schedulers not improve throughput linearly?
Show more question and Answers...

#

Comments & Discussions