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]
-XX:+PrintGC 與-verbose:gc 是一樣的,可以認為-verbose:gc 是-XX:+PrintGC的別名.
-XX:+PrintGCDetails 在啟動腳本可以自動開啟-XX:+PrintGC , 如果在命令列使用jinfo開啟的話,不會自動開啟-XX:+PrintGC
答案找到了,在官方文件中有說明:兩者功能一樣,都用於垃圾收集時的資訊列印。
-verbose:gc
穩定版
請參閱:http://docs.oracle.com/javase/7/docs/technotes/tools/windows/java.html
-XX:+PrintGC
非穩定版本,可能在未通知的情況下刪除,在下面官方文件中是-XX:-PrintGC。
因為被標記為manageable,所以可以用以下三種方式修改:
1、com.sun.management.HotSpotDiagnosticMXBean API
2、JConsole
3、jinfo -flag
參見:http://www.oracle.com/ technetwork/java/javase/tech/vmoptions-jsp-140102.html