NOTE
Java Reference Types
Strong, soft, weak, phantom, and reachability-related references, with practical cautions about caches and cleanup.
This is a historical learning note and may contain outdated or incomplete understanding.
1. Strong References
Ordinary Java references are strong references. As long as an object remains strongly reachable, normal GC will not reclaim it.
2. Soft References
SoftReference allows the referent to be reclaimed under memory pressure according to JVM policy. It should not be treated as a predictable cache-eviction mechanism; explicit bounded caches are easier to reason about operationally.
3. Weak References
A weakly reachable object can be cleared once it is no longer strongly/softly reachable. WeakHashMap and metadata associations are common examples where weak reachability is useful.
4. Phantom References
PhantomReference, normally used with ReferenceQueue, can support post-mortem lifecycle bookkeeping after the referent is no longer normally accessible. It is a low-level tool and does not resurrect the object for ordinary use.
5. Cleanup
Do not rely on finalization-style behavior for scarce external resources. Prefer deterministic cleanup (AutoCloseable, try-with-resources) and use Cleaner/reference mechanisms only when a fallback safety net is appropriate.