如何清除String Literal Pool中的条目 [英] How to clear the entry from String Literal Pool

查看:106
本文介绍了如何清除String Literal Pool中的条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

String.intern()的垃圾收集行为

Java如何存储字符串以及子字符串如何在内部工作?

根据我的声明,当声明为null时,String引用不会删除String文字池中的条目,我想知道如何清除它。

According to me the String reference when declared as null doesn't deletes the entry from String literal pool and i want to know how we can clear it .

    String object="csk";// creates an Object in Java Heap and makes an entry String Literal Pool .
    object=null// however make this reference to null object .

//但是它不会从字符串文字中删除一个条目。我怀疑它是否删除了一个条目来自Literal Pool

//but it doesn't deletes an entry from String literal .I doubt if it deletes an entry from Literal Pool

推荐答案

字符串文字(WeakHashMap)也存储在称为permgen堆的堆内存中。
需要在JVM中配置以查找和收集不再需要的动态加载的类,这可能导致字符串文字被垃圾收集。
和或当JVM执行Full gc时。

String literals (WeakHashMap) are also stored in heap memory called the "permgen" heap. need to configure in JVM to find and collect dynamically loaded classes that are no longer needed, and this may cause String literals to be garbage collected. and or when JVM performas the Full gc.

这篇关于如何清除String Literal Pool中的条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆