OOMKill Investigation: Find the Real Cause, Not Just Exit 137
OOMKill Investigation: Find the Real Cause, Not Just Exit 137

An OOMKill investigation answers three questions in order: did the kernel really kill the process for memory, which limit or pressure triggered it, and what made memory grow. The evidence sits in four places (pod status, kernel logs, memory metrics and workload logs), and each one disappears or goes stale on its own schedule. Opsphere connects to those tools without replacing them, so one investigation can read all of them from a single interface.
TL;DR
- Problem: Kubernetes records that a container was OOMKilled, but not why. The cause has to be rebuilt from the kernel log, cgroup counters and memory history.
- Key takeaway: First separate a container-limit kill from node-level memory pressure. The fix differs: raise or fix limits in one case, capacity or requests in the other.
- Do not trust exit code 137 alone. It means SIGKILL, which has other sources.
- Next step: Write the routine below into a runbook, alert on memory-to-limit ratio rather than on the kill itself, and keep the evidence in one place.
Table of Contents
- What the OOM killer does
- Step 1: Classify the kill
- Step 2: Confirm the kill and find the victim
- Step 3: Read the memory history
- Step 4: Check what counts toward the limit
- Step 5: Node-level kills and who dies first
- Step 6: Fix it and prove it will not recur
- Step 7: Alert before the kill
- Keeping the investigation in one place
- FAQ
- Sources
What the OOM killer does
OOM means out of memory. When a loaded Linux machine cannot reclaim enough pages, the kernel invokes the OOM killer, which picks a task and kills it so the rest of the system can keep running.
The victim is chosen by a badness score. According to the kernel’s OOM killer reference, the ideal victim is a recently started, unprivileged, memory-heavy process. Per Baeldung’s tutorial, oom_score runs 0 to 1000, and oom_score_adj (-1000 to 1000) shifts it, with -1000 making a process immune.
Two consequences matter for investigation:
- The process that triggered the OOM killer is often not the victim.
- The victim is often the biggest thing it was allowed to kill, such as a database or JVM, while the real cause was a small process that suddenly allocated a lot, as one Linux runbook notes.
Step 1: Classify the kill
There are three different events that engineers loosely call an OOMKill.
| Event | Trigger | What you see |
|---|---|---|
| Container-limit kill | One container’s cgroup hit its memory limit | Reason OOMKilled, exit 137, kernel line with oom_memcg and “Memory cgroup out of memory” |
| Node-level kill | The node ran out of memory | “Out of memory: Killed process”, global_oom, a SystemOOM node event |
| Eviction | Kubelet reclaims memory under node pressure | Pod status Failed, reason Evicted |
The k8s Beacon’s breakdown covers these signatures. CoreWeave’s diagnosis guide gives the quickest discriminator: constraint=CONSTRAINT_MEMCG means the container hit its own limit, CONSTRAINT_NONE means node-level pressure.
The distinction decides the fix. In a cgroup OOM, one unit hit its own limit while the host still had free memory, so adding host RAM changes nothing.
What exit code 137 does not prove
Exit 137 is 128 plus 9, SIGKILL. Rolling updates, pod deletions and node drains can also end in SIGKILL. A liveness probe failure or a container ignoring SIGTERM past its grace period also produces 137, but with reason Error rather than OOMKilled.
Even Reason OOMKilled is coarse. It comes from containerd watching the oom_kill counter in the cgroup’s memory.events, which counts kills by any OOM killer, so it does not say whether the limit or the node was the cause.
Step 2: Confirm the kill and find the victim
On Kubernetes, start with the pod:
- Run
kubectl describe podand look for Last State Terminated, Reason OOMKilled, Exit Code 137, as GKE’s troubleshooting guide describes. - After restarts, read
kubectl logs --previousand sort cluster events withkubectl get events --sort-by=.lastTimestamp, the sequence in Microsoft’s AKS guide. - Read the node’s kernel log:
dmesg -T | grep -i 'killed process\|oom'. Kubernetes stores no cause for the kill because SIGKILL cannot be caught; the kernel ring buffer is the record, and it names the killed process and its RSS.
On a plain Linux host, Result=oom-kill on the systemd unit is the unambiguous signal. Then read the task table printed before the kill with journalctl -k | grep -A80 'invoked oom-killer': the invoking line names the trigger, the table shows RSS per process and the Killed process line names the victim.
To map a kernel line to a pod, take the oom_memcg field, which holds the pod UID with underscores instead of hyphens. Convert it back and match it against kubectl get pods, per CoreWeave.
Kills Kubernetes never reports
A kill can happen without a pod restart. In cgroup v1, the OOM killer may terminate a child process while PID 1 keeps running, so Kubernetes does not see it. For these, search node logs for TaskOOM events and match the container ID to the following ContainerDied line, which typically carries the pod name. Journal entries mentioning memcg indicate a container-level kill. Teams running multi-process containers can read more on how container OOM handling differs in this guide to Kubernetes cluster management.
Cgroup v2 changes the behavior again. Since Kubernetes 1.28 on cgroup v2 nodes, the container cgroup gets memory.oom.group=1 so all tasks die together. The same write-up describes a team whose notebook memory overruns went from restarting a kernel to terminating the whole pod after an EKS upgrade, fixable with the kubelet’s singleProcessOOMKill setting.
Step 3: Read the memory history
Do not rely only on utilization metrics. GKE warns they are collected at intervals and often miss the rapid spike that triggers the kill.
Still, the shape of the curve is the best clue. Andrii Boyko describes three shapes:
| Memory shape | Likely cause | Direction of fix |
|---|---|---|
| Flat plateau near the limit, OOM at startup or small spikes | Limit too tight | Check the runtime heap cap first, then the limit |
| Sawtooth with a rising floor, oldest pod dies first, deploys “fix” it | Leak | Profile the leak |
| Memory tracks traffic, all replicas die together at peak | Workload changed shape | Bound per-request memory or concurrency |
A useful query set from Google’s worked GKE example: view container/memory/used_bytes, which climbs steadily then drops to zero at the kill, then query the container’s logs just before the crash. In that example the app was loading large image files entirely into memory.
In Prometheus, one SRE routine replays the 30 minutes before the incident using container_memory_working_set_bytes, container_memory_inactive_file_bytes and container_cpu_cfs_throttled_seconds_total. Our guide on how Prometheus monitoring works and where it hits limits covers the query side.
Step 4: Check what counts toward the limit
A working set that looks like a leak is sometimes not application memory. Per the cgroup v2 breakdown, the limit covers:
- anon: heap and stacks.
- file: page cache, mostly reclaimable.
- shmem and tmpfs: including emptyDir with medium Memory, charged to the writing container and not reclaimable under pressure.
- kernel and sock: kernel stacks, page tables, slab and network buffers.
Two documented surprises. A Java container sat near 11Gi while the process used about 3Gi, because about 8.8 GB was page cache from a 100Gi unrotated log file. And a memory-backed emptyDir with no sizeLimit was effectively sized to the pod’s memory limit; a restart did not empty it and the container failed to start.
While the container is alive, read memory.events (max, oom, oom_kill) and memory.stat. A rising oom_kill counter while host MemAvailable is healthy is conclusive evidence of a limit problem, not a capacity problem.
Step 5: Node-level kills and who dies first
When the node itself is short, QoS class decides the order. The kubelet evicts BestEffort first, then Burstable pods using the most above their request, and Guaranteed last. For kernel kills, oom_score_adj is -997 for Guaranteed and 1000 for BestEffort, and Burstable pods get a value derived from the request relative to node memory, so a Burstable pod with a small request can be near the front of the line even if it was far from its own limit.

Kubernetes itself explains that memory limits are enforced reactively by kernel OOM kills. Setting requests honestly is therefore part of the fix, not a formality.
Step 6: Fix it and prove it will not recur
GKE lists four common causes: an insufficient limit, undefined requests and limits, high or spiky load, and memory leaks. It also warns that OOM events can cascade, since fewer containers then handle the same traffic.
Match the fix to the cause you found:
- Tight limit: raise the limit and align the runtime heap cap with it.
- Leak: fix the code; a bigger limit only delays the next kill.
- Traffic-shaped: bound per-request memory or concurrency.
- Non-heap memory: rotate logs, size memory-backed volumes, account for page cache.
Verify with the same signals that found the problem: the memory curve across a full traffic peak, the oom_kill counter staying flat, and no new OOMKilled events.
Step 7: Alert before the kill
OOM kills are not emitted by application code and are visible only through the Kubernetes API server. Without a correlated signal you cannot tell a misconfiguration from an application bug. OpenTelemetry recommends the k8s_events receiver for cluster events and the kubeletstats receiver for pod and container memory.
Alert on the ratio, not the kill. Boyko suggests working set above roughly 85 to 90 percent of the limit for a sustained window, plus increase(container_oom_events_total[15m]) > 0 to catch child-process kills. A community runbook uses two tiers: a warning above 0.85 for 10 minutes with no page, and a critical above 0.95 for 20 minutes that pages on-call.
One team reports that adding an inactive_file condition cut false positives from 40% to 12%, and trend detection brought it to 5%. Keep the rule set small: Google SRE’s guidance says paging should focus on symptoms, and signals nobody uses in a dashboard or alert are candidates for removal. For more on this, see our Kubernetes monitoring best practices and anomaly detection monitoring guides.

Keeping the investigation in one place
The routine above crosses kubectl, node logs, Prometheus, Grafana and an incident tool. That is where small teams lose time: each step is simple, the context switching is not. The same SRE write-up reports that a Grafana deep link in alert notifications cut diagnosis from 30 minutes to 8, which shows how much of the work is finding the evidence.
Opsphere is an operational intelligence platform that unifies context across AWS, Kubernetes, observability, CI/CD and security tools through AI agents, MCP and more than 300 read-only operational tools. It connects to your existing tools without replacing them or duplicating telemetry, and it keeps those tools as the source of truth under strict read-only access. Plans: Community at 0 € per month, Developer at 19 € per month, Enterprise at 450 € per month and Team at 500 € per month, with Custom Solutions priced on request, all on the Opsphere pricing page.

After the incident, turn the findings into a blameless postmortem. If you want the next OOMKill to start with the container-versus-node question already answered, start with Opsphere and connect your Kubernetes and observability stack.
FAQ
Does exit code 137 always mean an OOMKill?
No. It means SIGKILL, which also follows liveness probe failures, ignored SIGTERM past the grace period, drains and pod deletions. Confirm with Reason OOMKilled and the kernel log line.
How do I tell a container limit kill from node memory pressure?
Read the kernel line. CONSTRAINT_MEMCG, oom_memcg and “Memory cgroup out of memory” indicate the container’s own limit. CONSTRAINT_NONE, global_oom and a SystemOOM node event indicate the node ran out.
Why is there no OOMKilled event for my crashing app?
A child process can be killed while PID 1 keeps running, especially on cgroup v1, so the kubelet records nothing. Search node logs for TaskOOM events and alert on container_oom_events_total.
Should I just raise the memory limit?
Only if the memory shape shows a tight limit. A rising floor points to a leak, and traffic-tracking memory points to unbounded per-request work. A higher limit only delays those.
Sources
- Concepts overview, The Linux Kernel documentation
- Linux Memory Overcommitment and the OOM Killer, Baeldung
- OOM_Killer, linux-mm.org Wiki
- OOMKilled (exit code 137): leak or limit?, The k8s Beacon
- How do I diagnose out-of-memory (OOM) errors on CKS?
- Runbook: Investigate an OOM kill, RunBook Academy
- Runbook: OOMKilled Containers and Node Memory Pressure
- Troubleshoot OOM events, Google Kubernetes Engine
- Troubleshoot OOMKilled errors in AKS clusters, Microsoft Learn
- GKE example troubleshooting scenario
- OOMKilled in Kubernetes: Tight Limit, Leak, or New Workload?
- Pods OOM Killed at 3 AM, SRE Engineering Practice
- OOMKilled and Nothing Else, Code With Karani
- Resource Management for Pods and Containers, Kubernetes
- Kubernetes Cluster Observability, OpenTelemetry
- High Memory Usage, SRE Runbooks
- Monitoring Distributed Systems, Google SRE
- Gestione Cluster Kubernetes
Recommended
- Evidence-Backed Operational Investigations
- Operational investigations that show their evidence
- Draft First, Run in 30–60 Minutes: Blameless Postmortems for SREs
- Operational context that carries across investigations
This article is provided for general informational purposes only and does not constitute professional, legal, security, or compliance advice. Please evaluate recommendations against your organization’s specific environment and requirements.
