Interview Prep/Linux/Performance & the USE Method

How do you diagnose a memory leak in a long-running process?

AdvancedProductionPerformance & the USE Method
Answer
  1. Confirm growth over time: pidstat -r -p <pid> 60 or RSS from monitoring; a sawtooth that returns to baseline is GC, a steady ramp is a leak.
  2. Check whether it is heap (AnonPages, smaps_rollup Anonymous), file mappings, or kernel memory (slabtop for SUnreclaim).
  3. Use language tools: Java heap dumps (jcmd <pid> GC.heap_dump), Go pprof, Python tracemalloc, native valgrind/heaptrack, or memleak-bpfcc -p <pid>.
  4. Mitigate while fixing with MemoryMax= and restarts, so the leak cannot take down the host.
All Linux questions Roadmap: Linux

More on Performance & the USE Method