WeakRefs
Weak references, abbreviated WeakRefs, are a mechanism in programming languages that allows a reference to an object without preventing that object from being reclaimed by the garbage collector. Traditional (strong) references keep an object alive as long as the reference exists, while a weak reference permits the garbage collector to free the object once no strong references remain, even if the weak reference is still accessible.
The concept originated in languages such as Smalltalk and C++ (via Boost's weak_ptr) and was later adopted
WeakRefs are commonly used in caching scenarios, identity maps, and listeners where the owner wants to avoid
Using a weak reference requires handling the possibility that the referent has been collected. In Java and
Although weak references provide powerful memory-management capabilities, they also introduce subtle behavior. Code must be defensive