我们可以避免在java中实现字符串吗? [英] Can we avoid interning of strings in java?

查看:112
本文介绍了我们可以避免在java中实现字符串吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以完全禁用字符串的实习。它可能不是真的有用,但只是一个想法。我可以想到至少有一点可以提供帮助,即在jvm调整期间,控制perm gen的大小。

Can we completely disable interning of strings. It might not be really helpful, but just a thought. I can think atleast one point where it could be helpful i.e. during jvm tuning, controlling the size of the perm gen.

例如如果我发布一个OSGI框架,任何人都可以添加任意数量的自己的捆绑包,每个捆绑字符串实习可以完全搞砸我的调整参数。 (当然我知道我们应该调整给定的固定发行版,但仍然......)

For e.g. if I give out an OSGI framework and anyone can add any number of bundles of their own and each bundles string interning can completely screw up my tuning parameters. (Ofcourse I know that we should do tuning on a given fixed distro, but still...)

任何想法!!

推荐答案

Permgen的大小/用法不是现代JVM的问题。当没有剩余的引用时,Interned字符串可用于垃圾收集器。

Permgen size/usage isn't an issue with modern JVMs. Interned strings are made available to the garbage collector when there are no remaining references to them.

(不,你不能关闭字符串文字的实习) 。

(And no, you can't "turn off" interning of string literals).

这篇关于我们可以避免在java中实现字符串吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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