Skip to content

OOM Killed

Error message

                Container died due to OOMKilled (exit code 137)
              

Quick summary

The container used more memory than its configured limit, so the kernel killed it to protect the system.

Why this happens

  • The container's memory limit is too low for the application's needs

  • The application has a memory leak that causes usage to grow over time

  • The application loads large datasets into memory at once

  • No memory limit is set and the node runs out of memory

Minimal example

✗ Broken code
resources:
  limits:
    memory: 128Mi  # too low for the application
✓ Fixed code
resources:
  limits:
    memory: 512Mi  # increased to match actual usage

The memory limit was too low (128Mi), causing OOMKilled. The fix increases it to 512Mi to match the application's needs.

How to diagnose

  • Check the Pod's exit code: kubectl describe pod <pod> — look for OOMKilled

  • Review memory usage with kubectl top pod <pod> or Grafana dashboards

  • Check the container's memory limits in the Pod spec

  • Use docker stats to monitor memory usage in real-time

How to fix

  • Increase the memory limit in the container spec: resources.limits.memory

  • Fix memory leaks in the application code

  • Optimize the application to use less memory (stream data instead of loading all)

  • Add memory request and limit based on observed usage patterns

How to prevent

  • Set appropriate memory requests and limits based on load testing

  • Monitor memory usage trends and adjust limits proactively

  • Use profiling tools to identify memory leaks early

Related Resources

Related Glossary

← Back to language