JVM -XX:+StringCache 参数?

2022-01-16 00:00:00 jvm java jvm-arguments jvm-hotspot

我最近在阅读 JRE 6 中可用的所有 JVM 参数 [Java VM选项]并看到了这个:

I was recently reading about all the JVM arguments available in JRE 6 [Java VM Options] and saw this :

-XX:+StringCache : 启用常用分配字符串的缓存.

-XX:+StringCache : Enables caching of commonly allocated strings.

现在我的印象是 Java 保留了一个实习(正确的词?)字符串池,并且在使用文字进行字符串连接之类的操作时,它不是创建新对象,而是将它们从该池中拉出.有没有人使用过这个论点,或者可以解释为什么需要它?

Now I was always under the impression that Java kept a pool of interned (correct word?) Strings and when doing something like String concatenation with literals it was not creating new objects, but pulling them from this pool. Has anyone ever used this argument, or can explain why it would be needed?

我尝试运行基准测试,看看这个参数是否有任何影响,并且无法让 Sun JVM 识别它.这是与:

I attempted to run a benchmark, to see if this argument had any effect and was unable to get the Sun JVM to recognize it. This was with:

java version "1.6.0_11"  
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode,
sharing)

所以我不确定这个论点是否有效.

So I'm not sure if this argument works at all.

推荐答案

我找不到一个甚至可以接受这个假设参数的 JVM - 所以我想没什么好说的了.

I have not been able to find a single JVM that even accepts this supposed argument - so I guess there's not much else to say.

相关文章