Few weeks ago I got opportunities on GoJakarta where I speak about basic concept on memory management, pointers and garbage collector.

On first part, I give some briefing information of classic stack and heap allocation. Golang already have Escape Analysis and we can use that to check when variable move from stack to heap.

The next part is pointers. I quite familiar with pointer because I start learn programming from C/C++ language. As far as I know, there is no popular programming language have this feature and now it appear again on Golang. I called pointer as god feature which is allow us to manipulate memory address (actually it just store memory address and used it :-p). However golang pointer is simpler than C/C++ because we doesn’t need deallocate our pointer and no arithmetic support for pointer. Younger coder may have difficulty on this, so I provide some simple example.

The last but not least is garbage collector (GC). Everyone know about Java GC and want better GC. Before version 1.5, many people still prefer Java GC because of its maturity and a lot of tuning option. But version 1.5 and later, Golang is a winner with better and realtime GC. Below is GC latency on golang.

  • 300 ms (Go 1.4)
  • 40 ms (Go 1.5)
  • 3 ms (Go 1.6)
  • ~1 ms (Go 1.7)
  • < 100 μs (Go 1.8)
  • < 100 μs even for very large heap (Go 1.9)

Check my full presentation at slideshare