In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Reference types: new, virtual reference, soft reference, weak reference
1. Soft reference (SoftReference)
If an object has only soft references and the current virtual machine stack has enough memory, the garbage collector will not reclaim it; instead, it will reclaim the objects to which these soft references point.
two。 The difference between WeakReference and soft reference
Once the garbage collector finds that there are only weak references on a block of memory, it will reclaim the memory regardless of whether the current memory space is sufficient or not.
two。 Improve memory performance through soft / weak references
1) when there is enough memory, there is no need to use soft references.
2) improve efficiency with cache
First go to the cache to query, query to return; if the query is not available, go to the database to query, store the acquired content in the cache, and return.
Eg: soft reference / weak reference caching
3) Why not use strong references for caching
Strong references cannot be recycled
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.