OOMKilled
OOMKilled is a Kubernetes container termination reason that appears when a container uses more memory than its limit and the Linux kernel kills it. The container exit code is typically 137.
What happens
OOM stands for Out Of Memory. Kubernetes does not make the kill decision. The kernel's cgroup memory controller enforces the limit and sends SIGKILL, which cannot be caught, so the application gets no chance to shut down gracefully. Kubernetes reports the result as OOMKilled.
512Mi"] --> B["Usage reaches limit"] B --> C["Kernel sends SIGKILL"] C --> D["OOMKilled
exit code 137"] D -->|"restartPolicy Always"| E["Container restarts"] classDef start fill:#DBEAFE,color:#1E293B classDef bad fill:#FEE2E2,color:#1E293B classDef ok fill:#D1FAE5,color:#1E293B class A,B start class C,D bad class E ok
Why 137
A process killed by a signal exits with 128 plus the signal number. SIGKILL is 9, so the code is 137.
| Signal | Number | Exit code |
|---|---|---|
| SIGTERM | 15 | 143 |
| SIGKILL | 9 | 137 |
| SIGSEGV | 11 | 139 |
Confirm it
kubectl describe pod api-server-7d9f8b-xkp2q -n production# Last State: Terminated# Reason: OOMKilled# Exit Code: 137 kubectl get pod api-server-7d9f8b-xkp2q -n production \ -o jsonpath='{.status.containerStatuses[0].lastState.terminated.reason}'Set limits from real usage
kubectl top pods -n production --sort-by=memoryresources: requests: memory: "256Mi" # reserved on the node limits: memory: "512Mi" # exceeding this means OOMKilledA reasonable starting point is peak observed usage plus 30 percent headroom.
Runtimes with their own heap need tuning:
- Node.js: set
--max-old-space-sizeto roughly 75 percent of the limit. - Java: use
-XX:MaxRAMPercentage=75.0, and use a container-aware JVM.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Killed soon after start | Limit too low | Measure and add headroom |
| Memory climbs steadily | Leak | Profile, a larger limit only delays it |
| Killed only at peak | Limit too tight | Raise limit or scale out |
RememberA pod in CrashLoopBackOff with exit code 137 is usually being OOMKilled on every restart.
Common MistakeSizing the limit from average usage. Spikes and garbage collection pauses then cross the limit.
Frequently Asked Questions
What triggers OOMKilled and why is the exit code 137?
The container's memory use reaches its limit and the kernel kills it with SIGKILL. The exit code is 128 plus 9, the SIGKILL signal number, which is why it is 137.
Is OOMKilled the same as a node eviction for memory pressure?
No. OOMKilled is a per-container limit being exceeded. Eviction is the kubelet removing pods when the whole node runs low on memory.
Will raising the limit always fix it?
Only if the workload legitimately needs more. For a leak, a higher limit just delays the kill, so profile the application.