Java.WeakReference

WeakReference 弱引用

1. 简介

"Weak reference objects, which do not prevent their referents from being made finalizable,

finalized, and then reclaimed. Weak references are most often used to implement canonicalizing

mappings." Ref[1]

弱引用对象(Weak reference objects), 该对象不会阻止 它们所引用的对象(their referents) 变为可完结的,已完结的,

接下来可以被回收的。弱引用通常被用来实现规范化的映射。

 

2. Weak reference Vs. Soft reference 

"Weak references are useful for mappings that should have their entries removed automatically

once they are not referenced any more (from outside). The difference between a SoftReference 

and a WeakReference is the point of time at which the decision is made to clear and enqueue the reference:

  • SoftReference should be cleared and enqueued as late as possible, that is, in case the VM is in danger of running out of memory.
  • WeakReference may be cleared and enqueued as soon as is known to be weakly-referenced." Ref[2]

弱引用对映射(mapping)很有用处,对于映射来讲,当它们的条目一旦不再被引用时就应该自动地从该映射中移除。

软引用和弱引用地区别是:决定进行清理和将引用入队的时间点。

 

Reference

1. WeakReference [已读]

http://docs.oracle.com/javase/7/docs/api/java/lang/ref/WeakReference.html

2. WeakReference [已读]

http://developer.android.com/reference/java/lang/ref/WeakReference.html

3. Java Weak Reference [已读]

http://javapapers.com/core-java/java-weak-reference/

该blog描述了以下四种Reference类型:

Strong Reference

Weak Reference

Soft Reference

Phantom Reference

javapapers.com: java相关的各种文章,质量不错。

4. Understanding Weak Reference [Todo]

https://weblogs.java.net/blog/2006/05/04/understanding-weak-references

5. Difference between WeakReference vs SoftReference vs PhantomReference vs Strong reference in Java [Todo]

http://www.javacodegeeks.com/2014/03/difference-between-weakreference-vs-softreference-vs-phantomreference-vs-strong-reference-in-java.html

6. Java References: From Strong to Soft to Weak to Phantom

https://www.rallydev.com/community/engineering/java-references-strong-soft-weak-phantom

 

你可能感兴趣的:(WeakReference)