A weak reference is a holder for a reference to an object, called the referent.
弱引用是对一个对象(称为referent)的引用的持有者。
If the minimum number of objects is already allocated, then a weak reference to the object is enqueued.
如果已经分配了最低数量的对象,则对象的弱引用被放置到队列中。
Weakly reachable: an object that is not strongly or softly reachable and can be accessed through a weak reference.
弱可及对象(weaklyreachable):不是强可及对象也不是软可及对象,并且能够通过弱引用访问的对象。
The weak reference from the long-lived object to the short-lived object is kept long after the short-lived object has been destroyed.
在短周期对象销毁后,长周期对象对短周期对象的弱引用依然会长久保留下来。
Weak references tell the garbage collector that it should collect an object if there are no references to it other than the weak reference.
弱引用告诉垃圾收集器如果某个对象除了弱引用之外没有其他任何引用,则应该收集该对象。
Returns the current generation number of the target of a specified weak reference.
返回指定弱引用的目标的当前代数。
Since this event is static, it will only hold onto the handler as a weak reference.
由于此事件为静态的,因此它仅将该处理程序保持为一个弱引用。
GC is a thread of very low priority, so a weak reference object may not be collected immediately.
因为垃圾回收器是一个优先级很低的线程,所以弱引用对象也不一定会马上就会被回收。
From above shall we say that an object can't have a soft reference and a weak reference at the same time?
从以上是否能看出,一个对象不能同时具有软引用和弱引用?
A weak reference permits the garbage collector to collect the object while still allowing the application to access the object.
弱引用允许应用程序访问对象,同时也允许垃圾回收器收集相应的对象。
Dead mappings could be eliminated by periodically scanning the map, calling get on each weak reference, and removing the mapping if get returns null.
可以通过周期性地扫描Map,对每一个弱引用调用get,并在get返回null时删除那个映射而消除死映射。
It would be nice if there was a way to be notified when the referent of a weak reference is garbage collected, and that is what reference queues are for.
如果有一种方法可以在弱引用的referent被垃圾收集时发出通知就好了,这就是引用队列的作用。
The Entry type, which is used to store the key-value mapping, extends WeakReference, so when expungeStaleEntries() asks for the next expired weak reference, it gets back an Entry.
用于存储键-值映射的Entry类型扩展了 WeakReference,因此当expungeStaleEntries()要求下一个失效的弱引用时,它得到一个 Entry。
If a pointer pointing to an object not in the graph, then the object is not a reachable object, and then garbage collector sets the slot to null in the short weak reference table.
如果一个指针指向一个不在图中的对象,那么此对象就是一个不可到达的对象,垃圾收集器就将短弱引用表相应的槽置空。
On the other hand, when you create a weak reference to an object, you do not extend the lifetime of the referent at all; you simply maintain an alternate way to reach it while it is still alive.
另一方面,在创建对一个对象的弱引用时,完全没有扩展referent的生命周期,只是在对象仍然存活的时候,保持另一种到达它的方法。
弱引用 。
弱引用 。
应用推荐