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

请教老师软引用在什么时候会被回收掉?gc第一次还是第二次? #202

Open
HangboQuan opened this issue Sep 22, 2023 · 0 comments

Comments

@HangboQuan
Copy link

image
看书的时候,也结合这一些博客来看,对这块的理解有点模糊:
第一种观点: 当内存充足时, gc不会回收软引用; 当内存不足时, gc会回收软引用
第二种观点: 当内存不足时, 先进行一次gc, 如果gc完之后还没有足够的空间, 再回收软引用

最开始我的理解是第二种观点,做了下实验之后,我又发现第一种观点好像也没错?
img_v2_d643eb99-10ab-4381-8a8d-6d4bdc2c309l_MIDDLE

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

1 participant