Do Java development or several years, today just know the Java memory Recovery algorithm, really ashamed of shame
The Java Virtual machine determines whether an object instance can be recycled, not a reference counting algorithm.
Because the reference counting algorithm is difficult to solve the problem that objects are referenced directly to each other.
So Java C # uses accessibility analysis to determine whether an object can be recycled.
The basic idea of this algorithm is to use a series of objects called "GC Root" as the starting point, starting from these nodes, search the path called the application chain, when an object to GC roots without any reference chain connected. This object is not available when it is proved, and can be reclaimed. The following figure object Object5,object6,object7 although it is related to each other, but no GC roots can reach them. So they can be recycled objects.