Skip to content
Preptima
hardScenarioConceptMidSeniorStaff

Memory keeps climbing in a Go service under load. How do you find out why, and what can you actually tune?

6 min readUpdated 2026-08-15

Answer

Short answer

Take a heap profile and compare two taken minutes apart, because the shape of the growth tells you whether it is a leak, a cache with no bound, or simply the collector letting the heap grow.

Keep garbage collection explicit in the answer because that is the concept the interviewer is actually trying to test. A good garbage collection explanation names the trade-off, the failure mode, and the evidence you would use before choosing. Use garbage collection once more at the decision point so the answer reads as judgement rather than a detached example.

Keep garbage collection explicit in the answer because that is the concept the interviewer is actually trying to test. A good garbage collection explanation names the trade-off, the failure mode, and the evidence you would use before choosing.

Was this answer helpful?

Likely follow-ups

  • What does GOGC=50 actually change, and what does it cost you?
  • Why does the process resident size stay high after the live heap shrinks?
  • Which is worse in Go, a large heap or a high allocation rate, and why?
  • How would a goroutine leak show up differently from a retained cache?

Related questions

Further reading