1. SoftReference: Cleared when GC is response to memory demand. Often used to implement memory-sensitive cache.
  2. WeakReference: Don’t prevent to be finalized. Often used to implement canonicalizing mapping. (Mapping only reachable object instances)
  3. PhantomReference: Are enqueued after determining to be reclaimed. Not automatically cleared by GC. Object referenced via phantom reference won’t be cleared by GC automatically until phantom reference cleared. 

What to read next

Previous / Next
Previous: java.lang.ref 參考型別 Next: LeetCode 中等題 - LRU Cache
More like this
Subscribe via RSS: Macro · Tech