▶ Interactive Lab

Virtual Threads vs OS Threads

Memory cost of spawning N threads under each model.

Advertisement
OS thread ~1-8MB stack each. Virtual thread ~few KB. Same number of threads → very different memory.

What you're seeing

OS threads have ~1-8MB stacks (the kernel pre-allocates). Virtual threads (Java Loom, goroutines, Erlang processes) start with a few KB and grow as needed. Massive memory difference at 100K+ threads.

Virtual threads enable "one thread per connection" at scale — what was once unimaginable now works for 1M concurrent users on commodity hardware.

★ KEY TAKEAWAY
OS threads: ~1MB stack each. Virtual threads: ~8KB. Million-thread programs become trivially possible.
▶ WHAT TO TRY
  • Slide threads up to 1M — see OS-thread memory explode.
  • Virtual threads scale linearly with thread count, with tiny overhead.