Kar started this conversation 3 months ago.
Virtual Thread memory leak in Java 19+ causing hangs in high-concurrency apps
Using virtual threads heavily in Java 19, my application gradually consumes native memory and freezes, even though thread counts are low. What’s happening?
Kar
Posted 3 months ago
On Java 19 (fixed by 19.0.2 and Java 20), there were known memory leaks related to virtual threads—especially when many short-lived threads were created rapidly or under debugging conditions. These leaks can prevent GC or cause native memory exhaustion, hanging the application ([turn0reddit15]). 🛠️ How to Fix • Upgrade to Java 20 or higher (the issue is resolved in these versions). • If upgrading isn’t feasible, reduce creation rate of virtual threads and group work in batches or reuse. • Monitor native memory usage using tools like JFR or profilers. • For long-running thread-heavy workloads, consider using platform threads or structured concurrency patterns.