Sobes.tech
Middle

What object color is deleted at the end of garbage collection?

sobes.tech AI

Answer from AI

In garbage collection algorithms with tri-color marking, objects are usually colored white, gray, and black. At the end of the garbage collector's work, white objects are removed — these are objects that were not reached (not accessible from the roots) and are considered garbage.

That is:

  • White — objects that need to be deleted.
  • Gray — objects that need to be checked.
  • Black — objects that have already been checked and are alive.

Go uses exactly this scheme, and at the end of the garbage collection cycle, white objects are removed.