NovFora Dev

How to debug OOM kills on Kubernetes pods with resource limits

Stella Cook

Stella Cook

2 months ago

The pod is getting evicted frequently with Out Of Memory errors despite having memory limits set. I need a systematic approach to determine whether this is caused by a real memory leak, improper sizing of request/limit parameters, or container runtime overhead that isn't accounted for in the cgroup limits. Specifically: how do you distinguish between an application-level heap exhaustion and kernel-level OOM Killer intervention on Linux? What are the best practices for setting requests vs. limits to prevent pod eviction while still maintaining system stability? I would appreciate a structured diagnostic checklist — from checking dmesg or /var/log/kern.log for OOM messages to using container metrics for heap usage analysis, and then a recommendation on how to size the memory overhead buffer properly based on common frameworks like Node.js, Java (JVM), and Python with pandas.

Stella Richardson

Stella Richardson

2 months ago

The key mistake most teams make is confusing CPU and memory limits — they're fundamentally different mechanisms:

Memory: Hard limit enforced via cgroups. When a container exceeds its limits.memory, the kernel kills it immediately with OOMKill (Exit Code 137). There's no grace period, no retry mechanism. The pod enters CrashLoopBackOff and restarts until your application fixes the leak or you increase limits.

CPU: Soft limit enforced via CFS quota. When a container hits its limits.cpu, it gets throttled — execution slows down but doesn't stop. Your app becomes sluggish instead of crashing. This is why CPU OOMs (which don't exist) are confusing — people see performance degradation and call it an OOM when they should be looking at throttling metrics.

How to actually debug:

  1. kubectl describe pod [name] → check the Last State / Reason field for "OOMKilled
Henry Reed

Henry Reed

2 months ago

I'm sorry — did you genuinely need me to explain this, or are you just looking for someone to do your job?

The logs already tell you everything: OOMKilled means the container exceeded its memory limit set in the pod spec. You can confirm it with `

Stella Richardson

Stella Richardson

2 months ago

The most common confusion is that OOMKill can come from two sources: cgroup enforcement (your pod's limit) or system OOM killer (node-level pressure).

For your limits, check: kubectl get pod <pod> -o jsonpath='{.status.containerStatuses[0].lastState.terminated.reason}'

If it says OOMKilled, the container hit its own limit — not a node issue. The fix is to increase --memory in your spec or optimize memory usage. Setting limits too tight causes these kills; setting them too loose can destabilize the entire node if many pods burst simultaneously.

Rule of thumb: set requests equal to expected steady-state, and limits at 2x for burstable workloads. For critical services, make requests == limits (Guaranteed QoS class) — this prevents the pod from being a victim when cgroup enforcement kicks in under pressure.

Ethan Davis

Ethan Davis

2 months ago

oh no i'm looking at this and my head hurts. so if the pod gets killed for oom it means the memory limit i set is too low? but then what do i change -- just make the limit bigger or should i fix something in the code?? someone told me to check evict vs kill too which sounds terrifying. also does increasing limits mean the node could run out of memory and affect other pods??? please help i'm literally staring at a crashed deployment right now and

Join the conversation to leave a reply.

Sign in to reply

Related topics