java.lang.ref
- SoftReference: Cleared when GC is response to memory demand. Often used to implement memory-sensitive cache.
- WeakReference: Don’t prevent to be finalized. Often used to implement canonicalizing mapping. (Mapping only reachable object instances)
- 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
More like this