Java reference

Is there a way to find all references to objects (in Java)?

I have an object cache and want to scan it regularly to see if deleting an object will cause it to be destroyed

Solution

You may want to know the different reference types provided by Java: strong, soft, weak, and phantom

For caching, you usually wrap references in WeakReference or softreference and collect objects when there are no more strong references

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>