Leave a Comment
How golang garbage collection works
It is a Mark-and-Sweep GC.
Phases:
-
Mark
- Stop-the-World: Set write barrier (to know how much was allocated during maark phase)
- Concurrent: Mark all memory which is still in use by the app
- Stop-the-World: Remove write barrier
- Concurrent: Sweep (it actually happens on new allocations)
Video from Bill Kennedy (very basic; great explanation of gc trace):
https://www.youtube.com/watch?v=q4HoWwdZUHs
Video from Uber:
https://www.youtube.com/watch?v=q1h2g84EX1M