How does the Go Garbage Collector work?
Updated Apr 28, 2026
Short answer
Go uses a concurrent, tri-color mark-and-sweep garbage collector optimized for low latency.
Deep explanation
The GC phase runs concurrently with the application (mutators). It paints objects Black (reachable, scanned), Grey (reachable, unscanned children), or White (unreachable). It scans from root objects (globals, stack vars), turning Grey to Black. Write barriers ensure memory safety if the application modifies pointers during the scan. White objects are then swept (freed).
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro