Memory Leak Diagnosis

Container OOMKill events, heap dumps, JVM tuning, Go pprof, Python tracemalloc, and RSS growth patterns.

Overview

Overview

A memory leak makes a process's RSS (Resident Set Size) grow steadily over time with no matching rise in load. Eventually the process passes its memory limit (the container limit or free OS memory) and the OOM killer ends it. In Kubernetes this shows up as OOMKilled with exit code 137.

The cycle repeats on its own. The process allocates objects, connections or file descriptors and never releases them. RSS climbs with no rise in load until it hits the container limit or free OS memory. The OOM killer ends the process with exit code 137, the process restarts, and the climb starts again. A restart hides the leak for a few hours; it never fixes it.

Key concepts

  • RSS growth over time
  • Heap dump (JVM)
  • Go pprof heap
  • OOMKilled (exit code 137)
  • finalization vs WeakReference (Java)

Interview questions

  • A Node.js service's memory usage grows 50 MB per hour and restarts every 8 hours. How do you find the leak?

Sign up free to read the full topic

More Troubleshooting topics

Start free on Cariara · Coding problems · System design studio