Interview Prep/Docker/Limits, logging, health checks and restarts

A Java container is OOM-killed at 512 MB. Why isn't the heap the whole story?

IntermediateScenarioLimits, logging, health checks and restarts
Answer

Situation read → JVM memory includes heap, metaspace, thread stacks, code cache and native buffers.

What I'd do →

  1. Use container-aware flags: -XX:MaxRAMPercentage=70.
  2. Check docker inspect -f '{{.State.OOMKilled}}' c and dmesg | grep -i oom.
  3. Add native memory tracking -XX:NativeMemoryTracking=summary and size the limit accordingly.

Why → The cgroup counts total RSS, not just heap.

Interview tip → Leave 25–30% headroom above heap.

All Docker questions Roadmap: Docker & containers

More on Limits, logging, health checks and restarts