开发者

Does anyone know of a good guide to configure GC in Java?

I'm having trouble with a JVM running an app, whose hea开发者_运维问答p memory looks like a comb. It's constantly jumping from 1.5 GB to 3 GB and slowly deteriorating to higher values. I'm using G1 GC algorithm, but have no idea how to configure it.

I do not have access to the code of the app I'm running and, needless to say, it's a rather large app.

So, bottom line, does anyone know of a good guide to configure GC in Java?


Tuning a JVM is a touch of art and science combined, there's no one answer for everyone. The situation you're seeing sounds like the default GC is doing a "mark now, sweep later" which can lead to pauses during the sweep. One set of options you can try:

JAVA_OPTS="-server -XX:-UseParallelGC -XX:-UseConcMarkSweepGC"

That combo of options basically runs another thread (well 2) in the background which constantly mark AND sweep the GC. The penalty you pay is a bit more CPU use but in this modern day of CPUs it's hardly noticeable for most people.

Here are all the options: http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

You really need to read as many articles on 'java performance tuning' via Google as you can find, you need to profile your application (verbose GC) to find out what it's doing to get the correct combination of params to Java. Like anything else, just blindly throwing out options without knowing what they do can lead to worse performance, not better.


Here it is Tuning Garbage Collection with the 5.0 Java Virtual Machine from Sun...oops Oracle ;-)

Here is the link for Java 6


Currently the most up-to-date resources for GC in a Hotspot VM are the two following:

  • Java Performance - contains a full chapter dedicated to GC tuning

  • Java One 2012 Advanced JVM Tuning - most of the talk is dedicated to GC tuning.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜