Java垃圾收集如何处理循环引用?据我所知,Java中的垃圾收集清除了一些对象,如果没有其他东西“指向”该对象的话。我的问题是,如果我们有这样的事情会发生什么:class Node {
public object value;
public Node next;
public Node(object o, Node n) { value = 0; next = n;}}//...some code{
Node a = new Node("a", null),
b = new Node("b", a),
c = new Node("c", b);
a.next = c;} //end of scope//...other codea, b,和c应该被垃圾收集,但它们都被其他对象引用。Java垃圾收集如何处理这个问题?(还是仅仅是内存流失?)
添加回答
举报
0/150
提交
取消