Difference between -XX:+PrintGC and -verbose:gc

Syed Aqeel Ashiq picture Syed Aqeel Ashiq · Apr 2, 2018 · Viewed 8.1k times · Source

I want to understand the difference between: -XX:+PrintGC and -verbose:gc Apparently these look similar.

This article doesn't list the verbose:gc http://www.oracle.com/technetwork/articles/java/vmoptions-jsp-140102.html

I also saw these two questions: How to redirect verbose garbage collection output to a file? and https://stackoverflow.com/a/1818039/2266682 but couldn't get much understanding.

Answer

apangin picture apangin · Apr 2, 2018

In JDK 8 -verbose:gc is an exact alias for -XX:+PrintGC.

However, -verbose:gc is a standard option, while -XX:+PrintGC is not.

-XX:+PrintGC is deprecated since JDK 9 in favor of unified logging option -Xlog:gc, see JEP 158.
-verbose:gc still works in JDK 9 and 10.