If the garbage collector discovers an object that is weakly reachable, the following occurs.
如果垃圾收集器发现了弱可及对象,就会出现下列情况。
Weakly reachable: an object that is not strongly or softly reachable and can be accessed through a weak reference.
弱可及对象(weakly reachable):不是强可及对象也不是软可及对象,并且能够通过弱引用访问的对象。
Note, however, that it may take multiple runs of the garbage collector before it finds and frees a weakly reachable object.
然而,请注意,垃圾收集器可能要运行多次才能找到并释放弱可及对象。
After processing the soft references, the set of weakly reachable objects is identified — objects for which no strong or soft references exist.
处理软引用之后,弱可及对象的集合被识别——这样的对象上不存在强引用或软引用。
Phantomly reachable: an object that is not strongly, softly, or weakly reachable, has been finalized, and can be accessed through a phantom reference.
虚可及对象(phantomly reachable):不是强可及对象、软可及对象,也不是弱可及对象,已经结束的,可以通过虚引用访问的对象。
The key point is that when the garbage collector runs, if it encounters a weakly reachable object, it will free the object the WeakReference refers to.
关键之处在于,垃圾收集器运行时如果碰到了弱可及对象,将释放WeakReference引用的对象。
The key point is that when the garbage collector runs, if it encounters a weakly reachable object, it will free the object the WeakReference refers to.
关键之处在于,垃圾收集器运行时如果碰到了弱可及对象,将释放WeakReference引用的对象。
应用推荐