What replaced PermGen with Metaspace, and how can you still get a Metaspace OOM?
⚡ Short Answer
Java 8 replaced fixed-size PermGen with Metaspace, which lives in native memory and auto-grows by default. You still OOM if classes/classloaders leak (e.g. repeated redeploys, dynamic proxy/bytecode generation) or if you cap it with -XX:MaxMetaspaceSize.
☕Coffee Chat Question
Concept Made Simple
“What replaced PermGen with Metaspace, and how can you still get a Metaspace OOM?”
🧠Mind Map Answer
Remember It Faster
🔥What If?
Think Beyond the Expected
Metaspace usage climbs every hot redeploy until OOM — root cause?
A classloader leak: old web-app classes can't be unloaded because something pins their ClassLoader, so each redeploy adds another full set of class metadata to Metaspace. Fix the pin (ThreadLocals, drivers, threads); restart instead of hot-redeploy in prod.
😂Real World
Frameworks that generate classes at runtime (CGLIB proxies, dynamic languages, lots of lambdas/anonymous classes) and repeated redeploys are the usual Metaspace-growth culprits.
🎯Interviewer's Expectation
Keywords they're listening for:
⚠️Common Mistakes
- ✗Assuming Metaspace can never OOM
- ✗Not monitoring Metaspace separately from heap
- ✗Hot-redeploying repeatedly in production
✅Best Practices
- ✓Monitor Metaspace; alert on per-redeploy growth
- ✓Prefer full restarts over hot redeploys in prod
- ✓Cap MaxMetaspaceSize to fail fast on leaks (carefully)
🔁Follow-up Questions
- 1How does this relate to a ClassLoader leak?
- 2Should you cap MaxMetaspaceSize in production?
- 3How do dynamic proxies inflate Metaspace?
🧩Related Technologies
Continue Learning with AI
Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly — AI is your learning companion, not a shortcut.
Plain-language foundations
I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner. Topic: Memory Areas (JVM) Interview question: "What replaced PermGen with Metaspace, and how can you still get a Metaspace OOM?" Please: 1. Explain the core idea in simple, plain language, using an everyday analogy. 2. Define any technical terms you use. 3. Walk through one small, concrete example. 4. Finish with a single sentence I can easily remember. Keep the tone friendly and assume I'm new to this topic.
Was this answer helpful?
⭐ Featured Products
Support our platform by exploring our recommended products.
As an Amazon affiliate, purchases through these links may earn us a small commission — at no extra cost to you. It helps keep Full Stack Interview Guru free.