zoukankan      html  css  js  c++  java
  • Java.WeakReference-SoftReference-PhantomReference

    Weak Reference, Soft Reference, Phantom Reference

    1. Introduction

    "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

    7. Finally understanding how references work in Android and Java (AAAA)

    https://medium.com/google-developer-experts/finally-understanding-how-references-work-in-android-and-java-26a0d9c92f83#.o2aa3dc6g

    8. Java.InnerClass 

    ---
  • 相关阅读:
    常见的线性结构
    Lambda表达式学习笔记
    Spring Security 入门 (二)
    Spring Security 入门(一)
    Eclipse 创建 Maven 项目
    初学 Spring MVC(基于 Spring in Action)
    蓝桥杯之入学考试
    Java 学习总结
    二叉搜索树和红黑树
    Detours 劫持
  • 原文地址:https://www.cnblogs.com/cwgk/p/4037450.html
Copyright © 2011-2022 走看看