TLDR Web Dev · ARTICLES & TUTORIALS

VIRTUAL THREADS ATE MY MEMORY: A WEB CRAWLER'S TALE OF SPEED VS. MEMORY

links.tldrnewsletter.com6 min read

Summary from the TLDR Web Dev newsletter

Switching a web crawler from platform threads to Java Virtual Threads improves speed, but also causes an OutOfMemoryError due to a lack of built-in backpressure. Virtual Threads allows downloads to race ahead, but without limits, the system quickly floods memory with unprocessed tasks. The fix is to introduce explicit concurrency control (like semaphores) to balance speed with memory.