BEAM Processes vs. OS Threads: Memory Footprint Showdown

A minimal BEAM process typically uses ~2-3 KB, whereas an OS thread (like those in Java) often consumes 1-2 MB of memory for its stack, making BEAM processes up to 1000x lighter.

The top 3

  1. BEAM Processes: Kilobytes vs. OS Threads: Megabytes: A newly spawned BEAM process typically consumes a mere 2-3 KB of memory, including its control block, stack, and heap. In stark contrast, a standard OS thread, especially in environments like the JVM, often requires 1-2 MB of stack space, making BEAM processes roughly 1,000 times more memory-efficient at inception.
  2. Scaling Concurrency: Millions on BEAM, Thousands on OS Threads: The drastically smaller memory footprint of BEAM processes is a cornerstone for its unparalleled scalability, enabling the Erlang VM to concurrently manage millions of lightweight processes on a single machine. In contrast, the substantial memory overhead of OS threads severely limits their practical concurrency to thousands, as system memory is quickly exhausted.
  3. Context Switch: Nanoseconds vs. Microseconds: The BEAM virtual machine can switch between its lightweight processes in nanoseconds, significantly faster than the microseconds typically required for an operating system to perform a context switch between its heavier threads, enabling superior responsiveness and throughput.

Sources

Open the full topic