In my application some parts needs to be executed for given time (in minutes typically). Since the application uses a lot of memory I found that in some cases given time can be reduced by running garbage collector (sometimes for long time). Is it possible to read somewhere time spend by garbage collector in given period so I can react on this and give my code more time for execution?
I already tried g1 garbage collector but I noticed some jvm crashes. Throughput is important in my case, so I need to know when garbage collectors are called, which stops the application for some time.
So I would like to know when during the execution the GC is called.
-Xloggc:gc.log
-XX:+PrintGCDetails
-XX:+PrintGCApplicationStoppedTime
-XX:+PrintGCApplicationConcurrentTime
Add these JVM flags to your application.
PrintGCApplicationStoppedTime
shows how much time the application was stopped at safepoint. Most of the time it's caused by the GC 'stop the world' although there are other reasons.
PrintGCApplicationConcurrentTime
is how much time the application worked without stopping
NB: Java 6 doest not support GC1
yet, so you have no value to add it in.