Understanding and Modifying Golang Garbage Collection Code

I have recently been doing some research on Golang garbage collection. I have installed Go from source on my machine and would like to understand how Golang garbage collection works in the codebase. So some questions have come across my mind:

  • Where can I get the documentation about the latest GC algorithm/step that Go uses?
  • If I want to understand the code relevant to GC in Go, which files/folder is a good starting point in the source code?
  • Does the master branch always contain the latest changes for Go GC ?

It is my understanding that Go does not maintain detailed documentation of the implementation details except in comments in the source code and the source code itself. The comment at the top of runtime/mgcsweep.go should help get you started.

1 Like

Hi, Thanks. Does the master branch of the source code always contain the latest version of Go GC ?

I believe so. The only “active” branches I see are master, release-branch.go1.19, and release-branch.go1.20. master was last modified several days ago and the other two branches seem to be about a month old.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.