How golang garbage collection works

It is a Mark-and-Sweep GC.

Phases:

  1. Mark

    1. Stop-the-World: Set write barrier (to know how much was allocated during maark phase)
    2. Concurrent: Mark all memory which is still in use by the app
    3. Stop-the-World: Remove write barrier
  2. 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

Similar Posts

LEAVE A COMMENT