Dev scratchpad. Digital garden

Memory analysis in Go

Mar 24, 2020 | Reading Time: 1 min

Generic references and points to consider when doing a memory analysis with go programming language.

  • Do pprof memory profiling .

  • Go returns memory to OS gradually. Typical time is ~5 minutes. If immediate return is needed, we could use FreeOSMemory . General recommendation is that if this is needed, manage memory alternatively.

  • Alternative for frequent allocated and reused objects is sync.Pool usage. This is tricky and have to be careful when doing this. Sample usage can be found in blog .

  • Excellant High performance go tips are avilable at this post . This talks about memory and GC too.

  • Garbage collection behaviour is well explianed at: Ardan labs Post 1 , Post 2 and Post 3 . Also there is this keynote explaining the evolution of Go’s garbage collector.