Heap def new generation total 9216K, used 3977K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000) eden space 8192K, 48% used [0x00000000fec00000, 0x00000000fefe27f0, 0x00000000ff400000) from space 1024K, 0% used [0x00000000ff400000, 0x00000000ff400000, 0x00000000ff500000) to space 1024K, 0% used [0x00000000ff500000, 0x00000000ff500000, 0x00000000ff600000) tenured generation total 10240K, used 0K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000) the space 10240K, 0% used [0x00000000ff600000, 0x00000000ff600000, 0x00000000ff600200, 0x0000000100000000) Metaspace used 3241K, capacity 4496K, committed 4864K, reserved 1056768K classspaceused 349K, capacity 388K, committed 512K, reserved 1048576K
解释:
首先看下第二行:def new generation total 9216K, used 3977K,很明显,说明新生代总大小为9216K也就是9M的空间大小,为什么是9M呢,因为这里计算的是8M的eden区域+1M的survior from区域,剩下一个survior to的区域加起来一共10M,而可用空间根据复制算法只有9M也是正确的。
然后看下:eden space 8192K, 48% used,可以看到即使不运行任何的代码我们也使用了4M左右的空间,那么这4M的空间是什么东西呢,这部分对象其实是JVM自身运行产生的一些对象,这里也会放到后面的文章进行解读。
Heap par new generation total 9216K, used 3977K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000) eden space 8192K, 48% used [0x00000000fec00000, 0x00000000fefe27f0, 0x00000000ff400000) from space 1024K, 0% used [0x00000000ff400000, 0x00000000ff400000, 0x00000000ff500000) to space 1024K, 0% used [0x00000000ff500000, 0x00000000ff500000, 0x00000000ff600000) concurrent mark-sweep generation total 10240K, used 0K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000) Metaspace used 3255K, capacity 4496K, committed 4864K, reserved 1056768K classspaceused 353K, capacity 388K, committed 512K, reserved 1048576K
如果去掉cms?
如果我们把上面的参数去掉-XX:+UseConcMarkSweepGC,会出现下面的内容:
1 2 3 4 5 6 7 8 9 10
Heap par new generation total 9216K, used 3977K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000) eden space 8192K, 48% used [0x00000000fec00000, 0x00000000fefe27f0, 0x00000000ff400000) from space 1024K, 0% used [0x00000000ff400000, 0x00000000ff400000, 0x00000000ff500000) to space 1024K, 0% used [0x00000000ff500000, 0x00000000ff500000, 0x00000000ff600000) tenured generation total 10240K, used 0K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000) the space 10240K, 0% used [0x00000000ff600000, 0x00000000ff600000, 0x00000000ff600200, 0x0000000100000000) Metaspace used 3238K, capacity 4496K, committed 4864K, reserved 1056768K classspaceused 349K, capacity 388K, committed 512K, reserved 1048576K Java HotSpot(TM) 64-Bit Server VM warning: Using the ParNew young collector with the Serial old collector is deprecated and will likely be removed in a future release
Java HotSpot(TM) 64-Bit Server VM warning: Using the ParNew young collector with the Serial old collector is deprecated and will likely be removed in a future release