Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java GC tuning for strings

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)

like image 685
Srujan Kumar Gulla Avatar asked Apr 09 '13 18:04

Srujan Kumar Gulla


People also ask

What is GC tuning in Java?

GC tuning is a process of optimizing GC parameters and heap generation sizes to fit the runtime usage of JVM memory, and has proven itself an effective way to reduce NameNode pause time, which in turn decreases request latency and increases throughput.

How can I increase my GC threads?

To modify the number of threads, use the flag-XX:ParallelGCThreads=#, where # is the number of threads (in our case, eight). Once you've enabled those flags, test the application and see how much performance you've gained. Ideally, your application should now run faster and have shorter GC pause times.

Is G1GC available in Java 8?

At this stage, we will focus on the tried and tested G1 GC which is available in Java 8, as well as Java 11 (Supported JDK for most ForgeRock applications).

How set GC application in Java?

The number of threads that the garbage collector can use is set by using the -XX:ParallelGCThreads flag added to our application startup parameters. For example, if we would like 4 threads to do the garbage collection, we would add the following flag to our application parameters: -XX:ParallelGCThreads=4.


1 Answers

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.

like image 51
Aleš Avatar answered Oct 03 '22 12:10

Aleš