My application is using gc flag "PrintGCApplicationStoppedTime" but when am running it with Java 9 it is failing with following error:
Unrecognized VM option 'PrintGCApplicationStoppedTime'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
This post indicate that option is deprecated but is there any alternative for the information printed by his flag or this information is no longer available?
Few things to know there:
First, well the answer here by @apangin sums up quite well that the PrintGCApplicationStoppedTime
prints the time spent inside safepoints.
In order to dump more details onto the safe points of your application you shall better make use of:
-XX:+PrintSafepointStatistics -XX:PrintSafepointStatisticsCount=1
Second, Java 9 plans to implement Unified GC logging under JEP#271 which at the same time would make use of the Unified JVM Logging under JEP#158
Going forward with which -Xlog
would be used as a new command-line option to control logging from all components of the JVM. The logging would thereby follow the syntax(quoted):
-Xlog[:option]
option := [<what>][:[<output>][:[<decorators>][:<output-options>]]]
'help'
'disable'
what := <selector>[,...]
selector := <tag-set>[*][=<level>]
tag-set := <tag>[+...]
'all'
tag := name of tag
level := trace
debug
info
warning
error
output := 'stderr'
'stdout'
[file=]<filename>
decorators := <decorator>[,...]
'none'
decorator := time
uptime
timemillis
uptimemillis
timenanos
uptimenanos
pid
tid
level
tags
output-options := <output_option>[,...]
output-option := filecount=<file count>
filesize=<file size in kb>
parameter=value
Where picking up few varied examples to learn from would be:
-Xlog:gc=trace:file=gctrace.txt:uptimemillis,pids:filecount=5,filesize=1024
- log messages tagged with 'gc' tag using 'trace' level to
a rotating fileset with 5 files with size 1MB with base name
'gctrace.txt' and use decorations 'uptimemillis' and 'pid'
- default output of all messages at level 'warning' to 'stderr'
will still be in effect
-Xlog:gc+rt+compiler*=debug,meta*=warning,svc*=off
- log messages tagged with at least 'gc' and 'rt' and 'compiler' tag
using 'trace' level to 'stdout' but only log messages tagged
with 'meta' with level 'warning' or 'error' and turn off all
messages tagged with 'svc'
- default output of all messages at level 'warning' to 'stderr'
will still be in effect
See also JDK 9 release notes where the implications of unified logging (-Xlog) are detailed:
http://jdk.java.net/9/release-notes#JDK-8145092
You'll see that PrintGCApplicationStoppedTime and several options have been removed.