What are the different OutOfMemoryError types, and what does each tell you?
⚡ Short Answer
'Java heap space' = heap full (leak or under-sized). 'GC overhead limit exceeded' = GC runs constantly reclaiming little. 'Metaspace' = class/classloader growth. 'Direct buffer memory' = off-heap NIO/Netty. 'unable to create native thread' = too many threads / OS limit. Each points to a different area.
☕Coffee Chat Question
Concept Made Simple
“What are the different OutOfMemoryError types, and what does each tell you?”
🧠Mind Map Answer
Remember It Faster
🔥What If?
Think Beyond the Expected
You hit 'unable to create native thread' but heap is healthy — what's wrong?
It's not heap — you've exhausted OS threads or native memory for thread stacks (e.g. a thread leak, or ulimit/-Xss too high × many threads). Fix the thread leak / use a bounded pool, or raise the OS thread limit.
😂Real World
The exact OOM message is a free diagnosis — it names the exhausted resource. Reading it correctly saves hours vs blindly bumping -Xmx (which only helps 'Java heap space').
🎯Interviewer's Expectation
Keywords they're listening for:
⚠️Common Mistakes
- ✗Always bumping -Xmx regardless of OOM type
- ✗Ignoring off-heap/native OOMs
- ✗Not enabling HeapDumpOnOutOfMemoryError
✅Best Practices
- ✓Read the OOM message to locate the area
- ✓Enable -XX:+HeapDumpOnOutOfMemoryError
- ✓Bound threads and off-heap buffers
🔁Follow-up Questions
- 1Why is 'GC overhead limit exceeded' often a precursor to heap OOM?
- 2How do you cap and monitor direct (off-heap) memory?
- 3What causes 'unable to create native thread'?
🧩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: Troubleshooting (JVM) Interview question: "What are the different OutOfMemoryError types, and what does each tell you?" 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.