对字符串进行Java GC调优 [英] Java GC tuning for strings

查看:611
本文介绍了对字符串进行Java GC调优的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

剖析应用程序我发现堆上有很多字符串。

在我的情况中,字符串是在堆上创建的,而不是实际的,它们不是文字。

当应用程序中的字符串数量非常高时,是否需要遵循特定的GC调整技术。



我偶然发现了GC设置 -XX:+ UseCompressedStrings或-XX + UseStringCache ,但不确定这会有所帮助。有没有人试过这些设置?



java版本1.6.0_22

Java™SE运行时环境(build 1.6.0_22-b04 )

Java HotSpot™64位服务器虚拟机(构建17.1-b03,混合模式)

解决方案

<与 -XX:+ UseCompressedStrings 有关,你应该看看这个问题:支持将压缩字符串放入HotSpot JVM?



并且,与 -XX + UseStringCache JVM -XX:+ StringCache参数?



顺便说一句。 Java 7带有很好的功能,可以在使用字符串时调整字符串缓存。请参阅 -XX:+ PrintSTringTableStatistics -XX:StringTableSize = n 。这样您可以优化字符串缓存大小。

Profiling the application I figured out that there are a lot of strings on heap.

In my situation, strings are created on heap and not interned and they are not literals.

Are there are specific GC tuning techniques to follow when the number of strings in the application are very high.

I stumbled across the GC settings -XX:+UseCompressedStrings or -XX+UseStringCache but not sure this will help. Did any body try these settings?

java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)

解决方案

Related to -XX:+UseCompressedStrings, you should have a look at this question: Support for Compressed Strings being Dropped in HotSpot JVM?

And, related to -XX+UseStringCache, have a look at : JVM -XX:+StringCache argument?

Btw. Java 7 comes with nice features that allow tuning of String cache when using the interned Strings. See -XX:+PrintSTringTableStatistics and -XX:StringTableSize=n. This way you can optimize the String cache size.

这篇关于对字符串进行Java GC调优的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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