Sobes.tech
Senior

What GC roots (entry points for the garbage collector) do you know?

sobes.tech AI

Answer from AI

GC roots are objects from which the traversal of the object graph begins to determine reachability in Java. The main GC roots include:

  • Local variables and parameters of current threads (on the call stack)
  • Active threads (Thread objects)
  • Static fields of classes (static variables)
  • Objects registered through JNI (Java Native Interface)

If an object is reachable from any of these roots, it is considered alive and not subject to garbage collection.