使用java -XX:+PrintCommandLineFlags -version查看一下
-XX:InitialHeapSize=132500864 //初始堆大小
-XX:MaxHeapSize=2120013824 //最大堆大小
-XX:+PrintCommandLineFlags //程序运行前打印出用户手动设置或者JVM自动设置的XX选项,因为我们执行时间加上了这个选项,所以这里会打印出来
-XX:+UseCompressedClassPointers // 默认开启类指针压缩
-XX:+UseCompressedOops // 默认开启对象指针压缩
-XX:-UseLargePagesIndividualAllocation
-XX:+UseParallelGC // 默认使用Parallel垃圾收集器
java version "1.8.0_221" // jdk版本
Java(TM) SE Runtime Environment (build 1.8.0_221-b11) // jre
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode) // Hotspot虚拟机,Server模式,混合编译
或者使用java -XX:+PrintFlagsFinal 查看亦可。可以看到UseParellelGC和UseParellelOldGC两个选项都是打开的,即JDK1.8中默认使用的是Parallel Scavenge和Parallel Old收集器组合。
我可也可以写一个堆溢出的小demo打印GC信息:
PSYoungGen total 6144K, used 3224K [0x00000000ff980000, 0x0000000100000000, 0x0000000100000000)
eden space 5632K, 57% used [0x00000000ff980000,0x00000000ffca6230,0x00000000fff00000)
from space 512K, 0% used [0x00000000fff80000,0x00000000fff80000,0x0000000100000000)
to space 512K, 0% used [0x00000000fff00000,0x00000000fff00000,0x00000000fff80000)
ParOldGen total 13824K, used 13440K [0x00000000fec00000, 0x00000000ff980000, 0x00000000ff980000)
object space 13824K, 97% used [0x00000000fec00000,0x00000000ff920338,0x00000000ff980000)
Metaspace used 2681K, capacity 4486K, committed 4864K, reserved 1056768K
class space used 286K, capacity 386K, committed 512K, reserved 1048576K
PSYoungGen 表示的是由Parallel Scavenge垃圾收集器管理的新生代,ParOldGen表示由Parallel Old管理的老年代。