OOMKilled Pod Diagnosis

Diagnose OOMKilled container failures in Kubernetes using metrics, heap dumps, and memory profiling.

Overview

Overview

OOMKilled is a pod termination state: the Linux kernel's OOM killer ended a container that exceeded its memory limit. The pod exits with reason OOMKilled and exit code 137 (128 + SIGKILL), and the process gets no warning, no graceful shutdown signal and no chance to write error logs; it simply stops and Kubernetes restarts it.

The kill is one turn of a loop that repeats until something changes.

  • The container's working set, the memory it is actively using, grows.
  • While it stays under limits.memory, the container keeps running.
  • Once it exceeds the limit, the kernel's OOM killer acts on the cgroup limit, memory.limit_in_bytes (memory.max on cgroup v2).
  • The process receives SIGKILL and exits with code 137.
  • Kubernetes restarts the container, the working set grows again, and the loop starts over.

Key concepts

  • OOMKilled
  • container_memory_working_set_bytes
  • Memory Limit
  • HeapDumpOnOutOfMemoryError
  • Memory Leak

Interview questions

  • How do you distinguish between a memory leak and a legitimate memory spike causing OOM kills?
  • What is the correct approach to setting memory requests and limits in Kubernetes to handle both baseline and spike usage?
  • How do you configure a JVM containerized application to avoid OOM kills from native memory exceeding the container limit?

Sign up free to read the full topic

More Troubleshooting topics

Start free on Cariara · Coding problems · System design studio