GC Roots This blog is about the a question I received: Are the GC roots of Minor GC and Major GC the same? GC Algorithm If we are asked to come up with a GC collection algorithm, we may think about a solution : in which we maintain the count of reference to some objects, if count drop to 0, we claim the memory. This is called Reference Count , which can’t solve the cyclic reference, is a wrong algorithm. The GC collection algorithm adopted by JVM is marking algorithm from GC roots. The GC roots sounds very mysterious, but its meaning is very simple: GC roots is the object that live outside Java heap and referring to object in Java heap. From the Hotspot JVM source code, we can see the following GC roots types: enum RootType { universe = 1 , jni_handles = 2 , threads = 3 , object_synchronizer = 4 , system_dictionary = 5 , class_loader_data = 6 , management = 7 , ...
Learn programming, still on the way