-XX:+PrintGCDetails
打印GC日志明细。
5423K->664K(9216K):新生代GC前内存占用5523K,GC后内存占用664K,新生代总容量9216K。
1385780K->1381029K(1393664K):GC前堆容量占用1385780K,GC后对内存占用1381029K,堆总容量1393664K
0.0098895 secs:GC所花时间
[Times: user=0.05 sys=0.00, real=0.01 secs] :GC时间明细,用户态0.05s,内核态0.00s,实际0.01s,有四舍五入操作。因为是并发执行GC所以,user+sys所占时间大于real时间,这是正常的。
2.728: [GC (Allocation Failure) [PSYoungGen: 5423K->664K(9216K)] 1385780K->1381029K(1393664K), 0.0098895 secs] [Times: user=0.05 sys=0.00, real=0.01 secs]
-verbose:gc
简版的打印GC日志,与-XX:+PrintGC结果一样
[GC (Allocation Failure) 65536K->10447K(251392K), 0.0229971 secs]
[GC (Allocation Failure) 75983K->16288K(251392K), 0.0115133 secs]
[GC (Allocation Failure) 81824K->20647K(251392K), 0.0091722 secs]
[GC (Allocation Failure) 86183K->28218K(316928K), 0.0136937 secs]
[GC (Allocation Failure) 159290K->42687K(316928K), 0.0317246 secs]
[GC (Allocation Failure) 173759K->57756K(460288K), 0.0150241 secs]
[GC (Allocation Failure) 316316K->78242K(463872K), 0.0289551 secs]
[GC (Allocation Failure) 336802K->84541K(731136K), 0.0341129 secs]
-XX:+PrintGC
简版的打印GC日志,与-verbose:gc结果一样
[GC (Allocation Failure) 65536K->10429K(251392K), 0.0217259 secs]
[GC (Allocation Failure) 75965K->16977K(251392K), 0.0089387 secs]
[GC (Allocation Failure) 82513K->22501K(251392K), 0.0069203 secs]
[GC (Allocation Failure) 88037K->29114K(316928K), 0.0093825 secs]
[GC (Allocation Failure) 160186K->40087K(316928K), 0.0149631 secs]
[GC (Allocation Failure) 171159K->56415K(456192K), 0.0420244 secs]
[GC (Allocation Failure) 313439K->73515K(461312K), 0.0242800 secs]
[GC (Allocation Failure) 330539K->85874K(721408K), 0.0203910 secs]
-XX:+PrintGCDateStamps
配合打印GC日志,前面输出GC时间点,单独设置此参数没有意义。
如:-XX:+PrintGCDateStamps -XX:+PrintGC
2020-02-29T09:07:32.600+0800: [GC (Allocation Failure) 1385780K->1380997K(1393664K), 0.0094945 secs]
2020-02-29T09:07:32.610+0800: [GC (Allocation Failure) 1385093K->1381029K(1393664K), 0.0098624 secs]
2020-02-29T09:07:32.620+0800: [GC (Allocation Failure) 1385289K->1380965K(1393664K), 0.0085901 secs]
2020-02-29T09:07:32.629+0800: [GC (Allocation Failure) 1385061K->1381005K(1401856K), 0.0091994 secs]
2020-02-29T09:07:32.640+0800: [GC (Allocation Failure) 1393621K->1380989K(1401856K), 0.0093073 secs]
-XX:+PrintGCTimeStamps
配合打印GC日志,前面输出JVM启动时长,单独设置此参数没有意义
如:-XX:+PrintGCTimeStamps -XX:+PrintGC
3.582: [GC (Allocation Failure) 1385780K->1380997K(1393664K), 0.0093394 secs]
3.592: [GC (Allocation Failure) 1385093K->1380997K(1393664K), 0.0094592 secs]
3.602: [GC (Allocation Failure) 1385257K->1380965K(1393664K), 0.0188495 secs]
3.621: [GC (Allocation Failure) 1385061K->1380997K(1401856K), 0.0101789 secs]
3.633: [GC (Allocation Failure) 1393613K->1380997K(1401856K), 0.0089099 secs]
-Xloggc:D:\gc.log
将GC日志输出到指定文件。
可以看出GC文件里面包含了JVM的相关参数,如版本号,对内存分配情况,启动参数等。可以看见GC输出使用的是-XX:+PrintGC -XX:+PrintGCTimeStamps这两个参数
Java HotSpot(TM) 64-Bit Server VM (25.91-b14) for windows-amd64 JRE (1.8.0_91-b14), built on Apr 1 2016 00:58:32 by "java_re" with MS VC++ 10.0 (VS2010)
Memory: 4k page, physical 8302960k(2638944k free), swap 16604060k(9563160k free)
CommandLine flags: -XX:InitialHeapSize=132847360 -XX:MaxHeapSize=2125557760 -XX:NewSize=10485760 -XX:+PrintGC -XX:+PrintGCTimeStamps -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC
3.379: [GC (Allocation Failure) 1385780K->1380997K(1393664K), 0.0073499 secs]
3.387: [GC (Allocation Failure) 1385093K->1381061K(1393664K), 0.0093804 secs]
3.397: [GC (Allocation Failure) 1385321K->1380997K(1393664K), 0.0090807 secs]
3.406: [GC (Allocation Failure) 1385093K->1381029K(1401856K), 0.0093862 secs]