The full picture
🎬 JVM runtime data areas
1 / 6The JVM's runtime data areas: a shared Heap and Metaspace, plus per-thread areas — the JVM stack (one frame per method call) and program counter.
- JVM stack — one per thread (default ~512KB–1MB,
-Xss). Deep recursion →StackOverflowError. Allocation/free is pointer arithmetic — this is why locals are cheap. - Heap — shared object space (
-Xms/-Xmx), internally generational for most collectors. Exhaustion →OutOfMemoryError: Java heap space. - Metaspace — class metadata in native memory, grows dynamically (
MaxMetaspaceSizeto cap). Leaking classloaders (hot redeploys!) →OutOfMemoryError: Metaspace. - Code cache — JIT-compiled native code; direct memory — NIO buffers outside the heap (watch it in container limits).