Skip to content

Memory Profiling

"The leak you can find is the one you can attribute. The leak you can attribute is the one whose retention path you can read."

Memory profiling answers what is alive in the heap right now, and what keeps it alive. Distinct from Allocation Profiling (which counts what was allocated), this section is about what was retained.


Scope

  • Heap snapshots: .hprof (Java), runtime.WriteHeapProfile (Go), tracemalloc (Python), .heapsnapshot (Node)
  • The dominator tree — "if X were collected, how much memory would be freed?"
  • Retained vs shallow size — the most-misread number in any heap tool
  • Eclipse MAT, VisualVM, Chrome DevTools heap snapshots, go tool pprof -alloc_space
  • Leak hunting: comparison snapshots ("before" / "after" diffs), growing collections
  • The GC-vs-leak distinction — high heap usage is not always a leak

Status

✅ Content-complete — all five tiers written (junior / middle / senior / professional / interview).