Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WeekHashMap弱引用 #5

Open
crazyqiang opened this issue Jul 18, 2017 · 1 comment
Open

WeekHashMap弱引用 #5

crazyqiang opened this issue Jul 18, 2017 · 1 comment

Comments

@crazyqiang
Copy link

”WeekHashMap 的这个特点特别适用于需要缓存的场景“ —— 针对博主说的这句话想到的:既然WeekHashMap是弱引用,那么不管内存是否紧张value都有可能会被回收 ; 而软引用,只有当内存不足时才会被回收,那岂不是用软引用更合适,而弱引用在内存泄漏方面更合适一些,博主怎么看?

@CarpenterLee
Copy link
Owner

这是我描述的误导,我的意思是(从WeekHashMap的角度说)WeekHashMap用作缓存比较合适,并不是说缓存场景中WeekHashMap是首选。通常缓存系统需要考虑两个问题:1.缓存大小限制,2.大小达到上限时的替换策略(LRU, FIFO)。从这两个标准上讲,将大小限制以及替换策略交给虚拟机并不是最好的选择。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants