search

Home  >  Q&A  >  body text

java - jvm参数-verbose:gc和-XX:+PrintGC有区别?

jvm调优,参数-verbose:gc和-XX:+PrintGC有什么具体的区别?还是说效果一样的,打印下了没发现什么差别。

参数1:

-XX:+PrintGC
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-Xloggc:C:\Users\ligj\Downloads\gc.log
Java HotSpot(TM) 64-Bit Server VM (24.80-b11) for windows-amd64 JRE (1.7.0_80-b15), built on Apr 10 2015 11:26:34 by "java_re" with unknown MS VC++:1600
Memory: 4k page, physical 4184440k(823480k free), swap 8367040k(3693052k free)
CommandLine flags: -XX:InitialHeapSize=805306368 -XX:MaxHeapSize=805306368 -XX:MaxNewSize=536870912 -XX:NewSize=536870912 -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseCompressedOops -XX:-UseLargePagesInpidualAllocation -XX:+UseParallelGC 
2016-01-22T01:42:26.325+0800: 8.799: [GC [PSYoungGen: 393216K->60289K(458752K)] 393216K->60361K(720896K), 0.1290115 secs] [Times: user=0.17 sys=0.00, real=0.13 secs] 
2016-01-22T01:42:35.849+0800: 18.322: [GC [PSYoungGen: 453505K->45971K(458752K)] 453577K->46043K(720896K), 0.1065373 secs] [Times: user=0.17 sys=0.00, real=0.11 secs] 
2016-01-22T01:42:48.524+0800: 30.999: [GC [PSYoungGen: 439187K->52498K(458752K)] 439259K->52578K(720896K), 0.1795032 secs] [Times: user=0.20 sys=0.00, real=0.18 secs] 

参数2:

-verbose:gc
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-Xloggc:C:\Users\ligj\Downloads\gc.log
Java HotSpot(TM) 64-Bit Server VM (24.80-b11) for windows-amd64 JRE (1.7.0_80-b15), built on Apr 10 2015 11:26:34 by "java_re" with unknown MS VC++:1600
Memory: 4k page, physical 4184440k(958020k free), swap 8367040k(3884064k free)
CommandLine flags: -XX:InitialHeapSize=805306368 -XX:MaxHeapSize=805306368 -XX:MaxNewSize=536870912 -XX:NewSize=536870912 -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseCompressedOops -XX:-UseLargePagesInpidualAllocation -XX:+UseParallelGC 
2016-01-22T01:49:18.778+0800: 7.315: [GC [PSYoungGen: 393216K->60678K(458752K)] 393216K->60686K(720896K), 0.1241514 secs] [Times: user=0.13 sys=0.05, real=0.12 secs] 
2016-01-22T01:49:27.794+0800: 16.332: [GC [PSYoungGen: 453894K->45567K(458752K)] 453902K->45583K(720896K), 0.1833980 secs] [Times: user=0.22 sys=0.00, real=0.18 secs] 
2016-01-22T01:49:39.641+0800: 28.179: [GC [PSYoungGen: 438783K->53967K(458752K)] 438799K->53983K(720896K), 0.1683523 secs] [Times: user=0.31 sys=0.00, real=0.17 secs] 
高洛峰高洛峰2770 days ago916

reply all(2)I'll reply

  • PHPz

    PHPz2017-04-17 16:54:00

    -XX:+PrintGC is the same as -verbose:gc. It can be considered that -verbose:gc is an alias of -XX:+PrintGC.
    -XX:+PrintGCDetails can automatically enable -XX:+PrintGC in the startup script. If If you use jinfo to open the command line, -XX:+PrintGC will not be automatically opened

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 16:54:00

    The answer is found, it is explained in the official documentation: both have the same function, and are used for information printing during garbage collection.

    -verbose:gc
    Stable version
    See: http://docs.oracle.com/javase/7/docs/technotes/tools/windows/java.html

    -XX:+PrintGC
    Unstable version, may be deleted without notice, in the official document below it is -XX:-PrintGC.
    Because it is marked as manageable, it can be modified in the following three ways:
    1, com.sun.management.HotSpotDiagnosticMXBean API
    2, JConsole
    3, jinfo -flag
    See: http://www.oracle.com/ technetwork/java/javase/tech/vmoptions-jsp-140102.html

    reply
    0
  • Cancelreply