Founding prices until 15 December: 30% off Pro, locked for life. See pricing

$ … OOMKilled (exit code 137)

OOMKilled and exit code 137 in Kubernetes

The container used more memory than its limit and the kernel killed it.

Kubernetes

What it means

Each container's memory limit is enforced by the kernel. Going over it doesn't slow the container down, it kills it: the Pod shows Reason OOMKilled and exit code 137 (128 + signal 9), and the kubelet restarts it.

Causes and fixes

Most likely first. Run the check, and if it matches, apply the fix.

1. The limit is below what the app needs at peak

Check:

kubectl describe pod <pod> | grep -B2 -A4 'Last State'
kubectl top pod <pod>

Fix: Set the limit above observed peak usage with headroom; set requests near normal usage.

2. A memory leak, or a cache with no bound

Check:

kubectl top pod <pod> --containers   # grows steadily until killed

Fix: Bound caches and fix the leak; for JVM or Node apps, set the heap size below the container limit.

3. The runtime ignores the container limit (an old JVM sizing its heap from the node's memory)

Check:

kubectl exec <pod> -- java -XX:+PrintFlagsFinal -version | grep MaxHeapSize

Fix: Use a container-aware runtime or set -Xmx (or MaxRAMPercentage) explicitly.

Fix it yourself

A live machine in your browser with this problem already on it. The grader checks the result.

Open the lab

No account needed for your first tries.

Related errors