关键之处在于,垃圾收集器在运行时可能会(也可能不会)释放软可及对象。
The key point is that when the garbage collector runs, it may or may not free an object that is softly reachable.
软可及对象(softlyreachable):不是强可及对象,并且能够通过软引用访问的对象。
Softly reachable: an object that is not strongly reachable and can be accessed through a soft reference.
弱可及对象(weaklyreachable):不是强可及对象也不是软可及对象,并且能够通过弱引用访问的对象。
Weakly reachable: an object that is not strongly or softly reachable and can be accessed through a weak reference.
虚可及对象(phantomly reachable):不是强可及对象、软可及对象,也不是弱可及对象,已经结束的,可以通过虚引用访问的对象。
Phantomly reachable: an object that is not strongly, softly, or weakly reachable, has been finalized, and can be accessed through a phantom reference.
在跟踪之后,垃圾收集器就识别软可及的对象——这些对象上除了软引用外,没有任何强引用。
After the trace, the collector identifies the softly reachable objects — these objects for which no strong references exist but soft references do.
处理软引用之后,弱可及对象的集合被识别——这样的对象上不存在强引用或软引用。
After processing the soft references, the set of weakly reachable objects is identified — objects for which no strong or soft references exist.
处理软引用之后,弱可及对象的集合被识别——这样的对象上不存在强引用或软引用。
After processing the soft references, the set of weakly reachable objects is identified — objects for which no strong or soft references exist.
应用推荐