7
votes

I am using Java 5 and our custom server application needs GC tunning, as some times we are experiencing 15-20 seconds pause on peak hours. We are running Java 5 on a server class machine with JVM args like -server -d64

Is there a way to tell which GC algorithm the JVM is currently using?

http://docs.oracle.com/javase/1.5.0/docs/guide/vm/gc-ergonomics.html

On server-class machines running the server VM, the garbage collector (GC) has changed from the previous serial collector (-XX:+UseSerialGC) to a parallel collector (-XX:+UseParallelGC). You can override this default by using the -XX:+UseSerialGC command-line option to the java command.

1) I want to know is that really happening?

my next question is I have added the following at command line arguments

-verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime -Xloggc:logs/gc.log

2) will they have any performance or behavioral effect on the running JVM except logging GC logs?

5

5 Answers

6
votes

you can use -XX:+PrintFlagsFinal to print out JVM parameters and their settings.

java -XX:+PrintFlagsFinal -server -version

3
votes

You can use jmap -heap <jvm_pid> to print java heap summary. For example, Intellij's heap summary is like the following if I run the jmap -heap 2592:

Attaching to process ID 2592, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.101-b13

using parallel threads in the new generation.
using thread-local object allocation.
Concurrent Mark-Sweep GC
Truncated...

As you you can spot from the output, the JVM instance running with 2592 process id is using CMS GC algorithm.

Also, if the algorithm was determined by those -XX:+Use*GC flags, you can find that using the jcmd <pid> VM.flags. For example:

$ jcmd 2715 VM.flags 
2715:
-XX:CICompilerCount=4 -XX:InitialHeapSize=268435456
-XX:MaxHeapSize=734003200 -XX:MaxNewSize=244318208 
-XX:MinHeapDeltaBytes=524288 -XX:NewSize=89128960 -XX:OldSize=179306496 
-XX:+UseCompressedClassPointers -XX:+UseCompressedOops 
-XX:+UseFastUnorderedTimeStamps -XX:+UseParallelGC 

As you can see that VM is using the Parallel GC.

1
votes

You can get the current gc(s) in use using the GarbageCollectorMXBeans.

And pretty much all logging has a performance affect.

1
votes

Attach Visual VM to your process and inspect the mbeans. If you've never used it before (it's part of the Oracle JDK download), you will likely have to install the MBean plugin (which is easy)

http://docs.oracle.com/javase/6/docs/technotes/guides/visualvm/

http://visualvm.java.net/mbeans_tab.html

0
votes

If the GC is becoming an issue I would recommend you take a look into Java RTS (real-time system).

Java RTS allows you to gain precise control on when the GC works. Meaning that you have utter control of the worst-case-scenario and, therefore, can simulate how your system will perform under the stressfull condition possible.