The mainstream implementation of the mainstream Business programming language (Java, C #, and even the old Lisp mentioned earlier) is called the reachability analysis to determine whether an object survives. The basic idea of this algorithm is to use a series of objects called "GC Roots" as the starting point, starting from these nodes to search down, the path of the search is called the reference chain (Reference Chain), when an object to the GC Roots no reference chain connected (in the case of graph theory, Is that this object is not available when the GC roots to this object is unreachable). As shown in 3-1, objects 5, 6, and object 7 are associated with each other, but they are not accessible to GC roots, so they will be judged as recyclable objects.
In the Java language, the objects that can be used as GC roots include the following:
The object referenced in the virtual machine stack (the local variable table in the stack frame).
The object referenced by the class static property in the method area.
The object referenced by the constant in the method area.
The object referenced by JNI (that is, generally speaking, the native method) in the local method stack.
Reference: http://blog.csdn.net/jtracydy/article/details/61416634
More:
http://blog.csdn.net/ochangwen/article/details/51406779
Accessibility analysis algorithms-determine which objects are garbage (go)