BEAM's Million-Process Memory Efficiency Champion

The BEAM VM's lightweight processes are exceptionally memory-efficient; creating a million of them uses approximately 2.5GB of RAM, a stark contrast to the estimated 8TB required for a million typical operating system threads.

The top 3

  1. BEAM's Ultra-Light Processes: KB vs. MB Footprint: A minimal Erlang BEAM process typically starts with an initial memory footprint of approximately 2-3 KB, including its control block, stack, and heap. This is significantly lighter, often 500-1000 times, than a standard JVM thread which commonly requires 1-2 MB.
  2. Isolated Heaps & Per-Process GC: No 'Stop-the-World' Pauses: Each BEAM process operates with its own private memory heap, enabling garbage collection to occur locally within individual processes without halting the entire system, a common issue in shared-heap runtimes. This isolation prevents system-wide memory issues and ensures fault tolerance.
  3. Shared Binary Pool: Efficient Large Data Handling: For large binary data (exceeding 64 bytes), BEAM employs a shared binary pool with reference counting. This strategy prevents full data copies when messages containing large binaries are passed between processes, significantly reducing memory consumption.

Sources

Open the full topic