Calculation of % of GC time in Java server
garbage-collection, jakarta-ee, java, jvm, performance
Solution
No, your calculation is not precise, because this way, you don't know the exact time for which the OS allowed your program to run.
Assuming that you want to consider the time for which the application was completely stopped by the GC (pause time), you can use the following JVM options:
-XX:+PrintGCApplicationConcurrentTime
-XX:+PrintGCApplicationStoppedTime
This options will make the JVM print something like this to stdout:
Application time: 3.3319318 seconds
Total time for which application threads were stopped: 0.7876304 seconds
Application time: 2.1039898 seconds
Total time for which application threads were stopped: 0.4100732 seconds
You can then sum up the times for which the application was stopped and divide it by the sum of application time plus the pause time to get the mutator utilization (fraction of time in which the application was not paused by GC).
See also http://prefetch.net/blog/index.php/2008/02/18/measuring-the-time-an-application-was-stopped-due-to-garbage-collection/
Problem
I am using jstat to get the total accumulated time for GC operations, i.e. GCT So, assume GCT is 2 seconds, and my JVM process started for 60 seconds, am I an running on Quad Core sever, so my % of GC is ``` 2 / 60 * 4 = 0.83% ``` Is my calculation above correct?