Search This Blog

Tuesday, November 13, 2018

Garbage Collection Roots

Garbage Collection Roots are objects that are assumed to be reachable by the virtual machine itself. Objects that are reachable from the GC roots remain in memory, objects that are not reachable are garbage collected.
Common GC Roots are objects on the call stack of the current thread (e.g. method parameters and local variables), the thread itself, classes loaded by the system class loader and objects kept alive due to native code.
GC Roots are very important when determining why an object is still kept in memory: The reference chain from an arbitrary object to the GC roots (Path to GC Roots...) tells who is accidentally keeping a reference.