Is there a way to determine which GC algorithm the JVM is using

I use Java 5, and our custom server application needs to configure GC, as sometimes we see a pause of 15-20 seconds during rush hours. We run Java 5 on a server class machine with JVM arguments such as -server -d64

Is there a way to determine which GC algorithm the JVM is 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 sequential collector ( -XX:+UseSerialGC ) to the parallel collector ( -XX:+UseParallelGC ). You can override this default value with the -XX:+UseSerialGC command-line -XX:+UseSerialGC for the java command.

1) I want to know if this is really happening?

my next question is: I added the following to the command line arguments

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

2) Will they have any performance or behavior effect to run the JVM other than GC logs?

+6
source share
5 answers

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

java -XX: + PrintFlagsFinal -server -version

+5
source

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

And pretty much all logging affects performance.

+1
source

Attach a visual virtual machine to your process and check mbeans. If you've never used it before (this is part of the Oracle JDK download), you will most 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

+1
source

You can use jmap -heap <jvm_pid> to print a java heap summary. For example, the Intellij heap count is as follows if I ran jmap -heap 2592 :

Joining process ID 2592, please wait ...
The debugger is attached successfully.
server compiler detected.
JVM Version 25.101-b13

using parallel streams in the new generation. selection of objects.
Parallel Mark Scan GC
Mustache ...

As you can see in the output, the JVM instance that works with process id 2592 uses the CMS GC algorithm.

Also, if the algorithm was defined with these -XX:+Use*GC flags, you can find this using jcmd <pid> VM.flags . For instance:

 $ 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, the VM uses Parallel GC.

+1
source

If GC becomes a problem, I would recommend you take a look at Java RTS (Real-Time System) .

Java RTS allows you to get precise control when working with the GC. This means that you are in full control of the worst case scenario and, therefore, you can simulate how your system will work under stressful conditions.

0
source

Source: https://habr.com/ru/post/908546/


All Articles