Skip to content
Illustration of Go Garbage collector work
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
main.go

README.md

go-gc

Illustration of Go Garbage collector work

Running

$ go run main.go

Press Ctrl+C when you feel like stopping; the memory will be cleaned and you'll see the resulting output with freed allocated memory:

Alloc = 0 MiB   TotalAlloc = 0 MiB      Sys = 68 MiB    NumGC = 0
Alloc = 7 MiB   TotalAlloc = 7 MiB      Sys = 68 MiB    NumGC = 1
Alloc = 15 MiB  TotalAlloc = 15 MiB     Sys = 68 MiB    NumGC = 2
Alloc = 15 MiB  TotalAlloc = 15 MiB     Sys = 68 MiB    NumGC = 2
Alloc = 0 MiB   TotalAlloc = 15 MiB     Sys = 68 MiB    NumGC = 3
You can’t perform that action at this time.