auto commit

This commit is contained in:
CyC2018
2019-03-21 22:19:52 +08:00
parent be00ec0881
commit c8b15be109
5 changed files with 9 additions and 4 deletions

View File

@ -122,10 +122,15 @@ public class Test {
Test b = new Test();
a.instance = b;
b.instance = a;
a = null;
b = null;
doSomething();
}
}
```
在上述代码中a 与 b 引用的对象实例互相持有了对象的引用,因此当我们把对 a 对象与 b 对象的引用去除之后,由于两个对象还存在互相之间的引用,导致两个 Test 对象无法被回收。
### 2. 可达性分析算法
以 GC Roots 为起始点进行搜索,可达的对象都是存活的,不可达的对象可被回收。