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

Java内存回收.md 如何判断一个常量是废弃常量描述不正确 #952

Open
wardseptember opened this issue Oct 12, 2020 · 0 comments
Open

Comments

@wardseptember
Copy link

@wardseptember wardseptember commented Oct 12, 2020

原文

运行时常量池主要回收的是废弃的常量。那么,我们如何判断一个常量是废弃常量呢?

假如在常量池中存在字符串 "abc",如果当前没有任何 String 对象引用该字符串常量的话,就说明常量 "abc" 就是废弃常量,如果这时发生内存回收的话而且有必要的话,"abc" 就会被系统清理出常量池。

字符串常量池已经在堆中开辟一块空间存储了,运行时常量池里面没有字符串常量了。回收方法区更谈不上回收字符串常量池了,这里是有点小问题的。

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

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.