Skip to main content

OOMKilled and exit code 137: reading the evidence correctly

Updated 10 min readMarkdown

OOMKilled with exitCode: 137 is one of the few Kubernetes failures that tells you exactly what happened: the kernel's out-of-memory killer terminated your container because it exceeded its cgroup memory limit. 137 is 128 + 9 — killed by signal 9, SIGKILL, which cannot be caught, handled or logged.

That precision is also the trap. Because the what is so clear, it is tempting to skip the why and apply the obvious fix: raise the limit. Sometimes that is right. Often it converts a container that died in 40 seconds into one that dies in 40 minutes, and moves the incident to a worse hour.

This article is about the evidence that tells the three real causes apart.

The three causes, and what distinguishes them

Every container-limit OOM kill is one of these:

Cause Memory shape over time The fix
A leak Sawtooth climbing over hours or days, never returning to baseline Fix the leak; a bigger limit only buys time
An allocation burst Flat, then a near-vertical spike within a scrape interval Bound the allocation — batch size, page size, concurrency
An undersized limit Stable and high, sitting just under the ceiling, killed by ordinary variance Raise the limit to match real steady-state demand

The distinction matters because two of the three are not fixed by more memory. And they are distinguished entirely by shape over time, which is precisely the thing your metrics may not have captured.

Why the memory graph so often looks innocent

cAdvisor scrapes container_memory_working_set_bytes on an interval — typically 15 to 60 seconds. The OOM killer acts in microseconds. A process that allocates 100 MB over four seconds and dies can do the entire thing between two samples, and every point you have will show the calm baseline before it.

This produces the most confusing artefact in Kubernetes triage: a container demonstrably OOMKilled at its 128 MiB ceiling, with a memory graph that never rises above 9 MiB.

Here is that exact case, drawn to scale:

A memory chart against a 128 MiB limit: the sampled line stays flat at about 8 MiB while the real allocation ramps in 8 MB steps straight through the limit, entirely between two scrape points

The kill was real. The graph was not wrong — it simply never looked at the right moment.

The sampled working set stayed at roughly 8 MB, about 6% of the limit. The kill was real. The graph was not wrong — it simply never looked at the right moment.

Warning: This is why "the memory graph is flat, so it cannot be memory" is an unsafe inference. A flat graph excludes a leak. It does not exclude a burst. The only sources that can see a burst are the application's own logs and the termination reason.

What actually proves it

Three pieces of evidence settle an OOM kill between them.

1. The termination record. Authoritative, and it survives the restart:

kubectl -n <namespace> get pod <pod> \
  -o jsonpath='{.status.containerStatuses[0].lastState.terminated}' | jq

reason: OOMKilled here means the cgroup limit was the boundary — not host pressure, and not the scheduler. A container killed because the node ran out of memory is evicted, which is a different event with a different signature.

2. The limit itself, as a number. Not the request, and not what the Helm chart says:

kubectl -n <namespace> get pod <pod> \
  -o jsonpath='{.spec.containers[0].resources.limits.memory}'

3. The application's own account of what it was doing. This is what makes a burst visible when metrics cannot see it. A process that logs its allocations — batch sizes, queue depths, buffer growth — writes the missing part of the graph into Loki for you.

In the investigation above, the logs carried the whole story: mode=balloon chunk_mb=8, then batch buffer growing with allocated_mb climbing 8 → 112 in 8 MB steps every half second, then silence at the ceiling. Two run cycles, both reaching 112 MB, both dying there.

Enumerate the causes, then eliminate them

A diagnosis you can trust is one that says what it ruled out, and why. This is the part that distinguishes analysis from a guess that happened to be right — and the three candidates are told apart entirely by shape over time:

Three small memory charts against the same limit: a leak climbing in a sawtooth, an allocation burst that is flat then near-vertical, and an undersized limit sitting stable just under the ceiling

Two of the three are not fixed by more memory, and the profile over time is what separates them.

Note the shape of the reasoning that follows from it. In the investigation above, "gradual memory exhaustion" is not dismissed as unlikely — it is eliminated because the working set is flat across the whole window while the logs show a burst, which is the leak profile's own signature failing to appear. "Host-level memory pressure" is eliminated because reason=OOMKilled at the container's own 128 MiB boundary does not require host pressure to explain it.

That is also where the honest caveat lives: node metrics were absent in this run, so host pressure could not be categorically excluded — only shown to be unnecessary. A report that quietly upgraded "not needed" to "impossible" would be easier to read and worse to rely on.

The fix is usually two changes, not one

The most common permanent fix for a burst OOM is a pair of coupled values:

  • the thing that controls how much is held in memory at once — batch size, page size, prefetch depth, worker concurrency; and
  • the memory limit itself.

They are coupled, and changing one without the other is how the incident recurs. The demo case is a textbook version: BATCH_SIZE had been raised in the live ConfigMap without raising the 128 MiB limit, so every batch exceeded the allowance.

Two details in that remediation are worth copying into your own postmortems.

Restarting is called out as harmful. The runbook says not to restart the pod without changing one of the two values, because it will die again on the next batch — which is exactly what the evidence shows happened, twice. "Restart it" is the default incident reflex and it is wrong here.

Verification is specified per step. Each change comes with the command that proves it landed: read the ConfigMap back and expect 500, read the Deployment's limit back and expect 256Mi, tail the logs and expect no allocation ramp. A remediation without a verification step is a suggestion.

Tip: A fix is only as good as its verification. In AlertiGate a remediation such as a rollout undo is proposed with the evidence it rests on, approved by a person other than the proposer, and then checked: if the new pods restart again, the action is marked as failed and its own rollback is proposed for approval. An unverified change is a suggestion.

Getting the evidence while it still exists

The practical problem with all of this is timing. The terminated container's logs age out of Loki's retention. The kube_state_metrics series for a deleted pod disappear when the pod does. If the ReplicaSet is replaced, even the pod name stops resolving.

An engineer who opens the incident at 09:00 is frequently looking at an empty window, and the honest conclusion — "the evidence is gone, raise the limit and see" — is how undersized limits get raised repeatedly for a workload that is actually bursting.

This is the specific gap automated investigation closes. AlertiGate groups the alerts into one incident and can start investigating within seconds, while the terminated container's logs are still in retention and the metrics series still exist. Each read is recorded as a tool call with its query, its cluster and its raw answer, so the investigation is a record of what was true at the moment of the kill, not a reconstruction from what survived until morning.

It also treats the three causes above as what they are: competing hypotheses. "A release lowered the limit", "the process is leaking" and "the node is under pressure" each predict something different, and each is confirmed or refuted on a record you can open. One honest limit from our own lab: telling "the limit was lowered" from "the process grew past the limit" is hard when both predict the kill at the limit, and the engine still names a slow leak correctly only about one time in three. When it cannot separate them, the confidence band says so.

And some of these never need an incident. A container climbing steadily toward its limit can be read off a trend line: in the lab, AlertiGate's forecast flagged a leaking container 17 to 18 minutes before its OOM kill, with no model call at all.

Where AlertiGate fits

Everything above can be done by hand. AlertiGate exists to do it at 03:05, the moment the alert fires, without sending your telemetry anywhere. Compared with the hosted AI SREs, three differences matter for an OOM kill:

  • It runs in your cluster. The working-set series, the termination record and the application's logs are read where they live, while they still exist. Nothing leaves your network except the call to the model you chose, and nothing at all if that model is your own.
  • An investigation costs cents, not dollars. On our lab scenario one cost $0.026 to $0.059 in model calls, paid to your provider. Cleric lists $5 per investigation and Datadog reports about $4 on average for Bits AI (both read 27 November 2026). A noisy week of OOM kills does not become a bill.
  • The fix waits for a person, and is checked. A change such as lowering BATCH_SIZE and raising the limit together is proposed with its evidence, approved by someone other than the proposer, and verified afterwards.

How the AI SRE tools compare goes through those trade-offs in detail, including the cases where AlertiGate is the wrong choice.

What to take away

  • 137 means SIGKILL; OOMKilled means the container's own cgroup limit was the boundary.
  • A flat memory graph rules out a leak, not a burst.
  • The application's own logs are the only source that can see a sub-scrape-interval spike.
  • The fix for a burst is bounding the allocation and sizing the limit — together, in one change.
  • A diagnosis is only as good as the hypotheses it explicitly eliminated.

If the container is restarting rather than being killed once, the neighbouring failure mode is CrashLoopBackOff, which has its own evidence order — and the two overlap, since a container that is OOM-killed on every start will end up in CrashLoopBackOff too. If a config value like BATCH_SIZE drifted out of band, Argo CD will show the live value against the repository's.

AlertiGate is a free, self-hosted AI SRE for Kubernetes: try it.

This article was written with AI assistance. It first appeared on alertigate.com.

About the author

No comments yet. Be the first to comment.