“孤岛"垃圾收集

2022-01-16 00:00:00 garbage-collection java

谁能解释一下垃圾收集的孤立岛的概念吗?

Could anyone please explain the concept of Island of isolation of Garbage Collection?

推荐答案

对象 A 引用对象 B.对象 B 引用对象 A.对象 A 和对象 B 都没有被任何其他对象引用.那是一座孤岛.

Object A references object B. Object B references object A. Neither object A nor object B is referenced by any other object. That's an island of isolation.

基本上,隔离岛是一组相互引用但不被应用程序中任何活动对象引用的对象.严格来说,即使是单个未引用的对象也是一个孤立的孤岛.

Basically, an island of isolation is a group of objects that reference each other but they are not referenced by any active object in the application. Strictly speaking, even a single unreferenced object is an island of isolation too.

从评论

class A {
   B myB; 
} 
class B { 
   A myA; 
} 

/* later */  
A a = new A(); 
B b = new B();  
a.b = b; 
b.a = a;

相关文章