Skip to main content
DevOps Insightsguides & answers

Kubernetes · intermediate

OOMKilled and Exit Code 137: Limit, Leak or Spike?

Short answer

OOMKilled means the Linux kernel stopped your container because memory ran out, usually because it went over its own memory limit. Before raising the limit, look at the shape of the usage: flat and close to the limit means the limit is too low; a steady climb to the same ceiling every time means a leak; normal usage with an occasional kill means a spike. Each needs a different fix.

N
Neeraj Jha
3 min read
On this page · 3 sections
Diagram of Reading the memory curve: 1. Flat, near the limit, 2. Raise the limit, 3. Steady climb, regular kills, 4. Fix the code, 5. Fine, then one big request, 6. Size for the peak.

What the kernel did

You give a container a memory limit. When it uses more, the kernel kills it immediately, with no chance to clean up, and Kubernetes records Reason: OOMKilled, normally with Exit Code: 137. On its own, 137 only says the process was killed by a signal; the reason is what confirms memory.

bash
kubectl describe pod POD | grep -A5 'Last State'

Three shapes, three answers

Sample usage several times over a few minutes:

bash
kubectl top pod POD --containers
Reading the memory curve

1. Flat, near the limit. The workload simply needs more than it was given.

1 / 6

For the first case, watch a normal cycle first, including startup. Then raise the limit above the peak you saw, using your own numbers in place of these:

bash
kubectl set resources deployment NAME --limits=memory=512Mi --requests=memory=256Mi

When it is not the container's fault

Occasionally the node itself runs short of memory, and the kernel picks a victim, starting with pods that set no requests (the memory a pod tells the scheduler it needs) or that use far more than they asked for. Look for a SystemOOM warning on the node:

bash
kubectl describe node NODE

The fix there is accurate requests, so the scheduler stops packing more onto the node than it can hold.

The full page is OOMKilled (exit code 137). If the kills show up as a restart loop, CrashLoopBackOff explains the loop, and the exit code explainer decodes 137 and the others.

Enjoyed this article?

Get more DevOps insights delivered to your inbox.

Get new posts by email

Subscribe to get an email when a new blog post is published. Skip anytime.

No spam, unsubscribe anytime.

N

Written by

Neeraj Jha

Platform administrator and lead writer.

View all posts →

Discussion

0 comments

Sign in to join the conversation.

Be the first to comment

Start a conversation about this post

Share: