Kubernetes Error: OOMKilled (Exit Code 137)
Diagnose and fix Kubernetes OOMKilled (Out of Memory) exit code 137 when containers exceed memory limits or experience memory leaks.
Symptoms
kubectl get podsshows restarts and statusOOMKilledorCrashLoopBackOff.kubectl describe pod <name>showsLast State: Terminated,Reason: OOMKilled,Exit Code: 137.
Why It Happens
Exit Code 137 ($128 + 9$, SIGKILL) occurs when the Linux kernel's Out-Of-Memory (OOM) Killer terminates the container process because its physical RAM usage exceeded the resources.limits.memory configured in the PodSpec.
Common causes:
- Memory Limit Configured Too Low: Default application runtime memory requirements (e.g. Node.js V8 heap or JVM) exceed the limit.
- Memory Leak: Application retains references to uncollected objects across HTTP requests.
- Heavy In-Memory Operations: Unbuffered file uploads, large database query result sets loaded entirely into RAM.
- JVM / V8 Heap Misconfiguration: Node.js or Java heap size not constrained relative to the container limit.
How to Diagnose
Look for:
```text
Last State: Terminated
Reason: OOMKilled
Exit Code: 137
Started: Tue, 01 Oct 2026 10:15:00 +0000
Finished: Tue, 01 Oct 2026 10:18:22 +0000
```Solutions & Fixes
1. Increase Pod Memory Limits
Update resources.limits.memory in your Deployment YAML:
spec:
containers:
- name: api-server
image: my-app:latest
resources:
requests:
memory: "512Mi"
cpu: "250m"
limits:
memory: "1024Mi" # Increased from 256Mi to 1Gi
cpu: "1000m"2. Configure V8 Max Old Space for Node.js
Ensure Node.js triggers garbage collection before the container memory limit is reached:
spec:
containers:
- name: nextjs
image: my-app:latest
env:
# Set max heap size to ~75% of container limit (e.g. 768MB of 1GB limit)
- name: NODE_OPTIONS
value: "--max-old-space-size=768"
resources:
limits:
memory: "1024Mi"3. Stream Large Payloads & Paginate Database Queries
Avoid reading entire 500MB database dumps or files into RAM:
- Use streaming pipelines (
fs.createReadStream). - Use database pagination (
take: 50, skip: 0).
Related Topics
Kubernetes Error: ImagePullBackOff / ErrImagePull
Fix ImagePullBackOff and ErrImagePull errors caused by non-existent container images, invalid tags, private registry authorization failures, or rate limits.
Kubernetes Error: Pod Stuck in Pending State
Fix Kubernetes Pods stuck in the Pending state due to insufficient CPU/memory capacity, node taints, unbound PVCs, or affinity rules.