Image

Imagenaoe_riki wrote in Imagejava_dev

Garbage Collector: Dealing with circular references

To me this seems to be the most appropriate place in LJ to post this question, so here it goes:

Garbage Collector in Java. How does it actually deal with circular references? You know, circular references is what makes it impossible for GC to operate only by storing the number of references to each object. So I suppose there is some other way.. Well, imagine two objects "containing each other" (is that possible?) and no other objects, and forced to be deleted together with the other object when it is deleted.

If not permitted to mark an object as "to-be-deleted", exactly how does the Java Garbage Collector operate in this case?