Is there any way to find all references to an object (in Java)?
I have a cache of objects, and would like to periodically scan it to see if removing the object will cause it to be destroyed.
You might want to take a look at different reference types Java provides: strong, soft, weak, and phantom.
For cache you would normally wrap a reference into WeakReference or SoftReference and let the object be collected once there are no more strong references left.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With