测试代码:
public class demonopara {
private static final int _1MB = 1024*1024;
public static void main(String[] args) {
// TODO Auto-generated method stub
byte[] allocation1,allocation2,allocation3,allocation4;
allocation1 = new byte[2 * _1MB];
allocation2 = new byte[2 * _1MB];
allocation3 = new byte[2 * _1MB];
allocation4 = new byte[4 * _1MB];
}
}
JVM参数:-verbose:gc -Xms20M -Xmx20M -Xmn10M -XX:+PrintGCDetails -XX:SurvivorRatio=8(堆大小20M,不可拓展,10M新生代,10M老生代,Eden和Survivor的比例是8:1,OK)
1.Parallel Scavenge + Serial Old(-XX:+UseParallelGC)
Heap
PSYoungGen total 9216K, used 7159K [0x00000007ff600000, 0x0000000800000000, 0x0000000800000000)
eden space 8192K, 87% used [0x00000007ff600000,0x00000007ffcfde20,0x00000007ffe00000)
from space 1024K, 0% used [0x00000007fff00000,0x00000007fff00000,0x0000000800000000)
to space 1024K, 0% used [0x00000007ffe00000,0x00000007ffe00000,0x00000007fff00000)
ParOldGen total 10240K, used 4096K [0x00000007fec00000, 0x00000007ff600000, 0x00000007ff600000)
object space 10240K, 40% used [0x00000007fec00000,0x00000007ff000010,0x00000007ff600000)
PSPermGen total 21504K, used 2611K [0x00000007f9a00000, 0x00000007faf00000, 0x00000007fec00000)
object space 21504K, 12% used [0x00000007f9a00000,0x00000007f9c8cc78,0x00000007faf00000)
2.Serial+Serial Old(-XX:+UseSerialGC)
[GC[DefNew: 6995K->240K(9216K), 0.0044170 secs] 6995K->6384K(19456K), 0.0044380 secs] [Times: user=0.01 sys=0.01, real=0.01 secs]
Heap
def new generation total 9216K, used 4666K [0x00000007f9a00000, 0x00000007fa400000, 0x00000007fa400000)
eden space 8192K, 54% used [0x00000007f9a00000, 0x00000007f9e527b0, 0x00000007fa200000)
from space 1024K, 23% used [0x00000007fa300000, 0x00000007fa33c198, 0x00000007fa400000)
to space 1024K, 0% used [0x00000007fa200000, 0x00000007fa200000, 0x00000007fa300000)
tenured generation total 10240K, used 6144K [0x00000007fa400000, 0x00000007fae00000, 0x00000007fae00000)
the space 10240K, 60% used [0x00000007fa400000, 0x00000007faa00030, 0x00000007faa00200, 0x00000007fae00000)
compacting perm gen total 21248K, used 2614K [0x00000007fae00000, 0x00000007fc2c0000, 0x0000000800000000)
the space 21248K, 12% used [0x00000007fae00000, 0x00000007fb08d840, 0x00000007fb08da00, 0x00000007fc2c0000)
No shared spaces configured.
3.ParNew + Serial Old(-XX:+UseParNewGC)
[GC[ParNew: 6995K->282K(9216K), 0.0039460 secs] 6995K->6426K(19456K), 0.0039770 secs] [Times: user=0.01 sys=0.01, real=0.00 secs]
Heap
par new generation total 9216K, used 4708K [0x00000007f9a00000, 0x00000007fa400000, 0x00000007fa400000)
eden space 8192K, 54% used [0x00000007f9a00000, 0x00000007f9e527b0, 0x00000007fa200000)
from space 1024K, 27% used [0x00000007fa300000, 0x00000007fa346a50, 0x00000007fa400000)
to space 1024K, 0% used [0x00000007fa200000, 0x00000007fa200000, 0x00000007fa300000)
tenured generation total 10240K, used 6144K [0x00000007fa400000, 0x00000007fae00000, 0x00000007fae00000)
the space 10240K, 60% used [0x00000007fa400000, 0x00000007faa00030, 0x00000007faa00200, 0x00000007fae00000)
compacting perm gen total 21248K, used 2614K [0x00000007fae00000, 0x00000007fc2c0000, 0x0000000800000000)
the space 21248K, 12% used [0x00000007fae00000, 0x00000007fb08d840, 0x00000007fb08da00, 0x00000007fc2c0000)
No shared spaces configured.
4.Parallel Scavenge + Parallel Old(-XX:+UseParallelOldGC)
Heap
PSYoungGen total 9216K, used 7159K [0x00000007ff600000, 0x0000000800000000, 0x0000000800000000)
eden space 8192K, 87% used [0x00000007ff600000,0x00000007ffcfde20,0x00000007ffe00000)
from space 1024K, 0% used [0x00000007fff00000,0x00000007fff00000,0x0000000800000000)
to space 1024K, 0% used [0x00000007ffe00000,0x00000007ffe00000,0x00000007fff00000)
ParOldGen total 10240K, used 4096K [0x00000007fec00000, 0x00000007ff600000, 0x00000007ff600000)
object space 10240K, 40% used [0x00000007fec00000,0x00000007ff000010,0x00000007ff600000)
PSPermGen total 21504K, used 2611K [0x00000007f9a00000, 0x00000007faf00000, 0x00000007fec00000)
object space 21504K, 12% used [0x00000007f9a00000,0x00000007f9c8cc78,0x00000007faf00000)
5.ParNew + CMS + Serial Old(-XX:+UseConcMarkSweepGC)
[GC[ParNew: 7003K->289K(9216K), 0.0046330 secs] 7003K->6435K(19456K), 0.0046730 secs] [Times: user=0.02 sys=0.01, real=0.00 secs]
[GC [1 CMS-initial-mark: 6146K(10240K)] 10531K(19456K), 0.0002410 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
Heap
par new generation total 9216K, used 4715K [0x00000007f9a00000, 0x00000007fa400000, 0x00000007fa400000)
eden space 8192K, 54% used [0x00000007f9a00000, 0x00000007f9e527a8, 0x00000007fa200000)
from space 1024K, 28% used [0x00000007fa300000, 0x00000007fa348520, 0x00000007fa400000)
to space 1024K, 0% used [0x00000007fa200000, 0x00000007fa200000, 0x00000007fa300000)
concurrent mark-sweep generation total 10240K, used 6146K [0x00000007fa400000, 0x00000007fae00000, 0x00000007fae00000)
concurrent-mark-sweep perm gen total 21248K, used 2615K [0x00000007fae00000, 0x00000007fc2c0000, 0x0000000800000000)
[GC pause (young) (initial-mark), 0.0014180 secs]
[Parallel Time: 1.0 ms, GC Workers: 8]
[GC Worker Start (ms): Min: 120.1, Avg: 120.2, Max: 120.6, Diff: 0.5]
[Ext Root Scanning (ms): Min: 0.0, Avg: 0.2, Max: 0.4, Diff: 0.4, Sum: 1.9]
[Code Root Marking (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
[Update RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
[Processed Buffers: Min: 0, Avg: 1.1, Max: 5, Diff: 5, Sum: 9]
[Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
[Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
[Object Copy (ms): Min: 0.4, Avg: 0.5, Max: 0.6, Diff: 0.2, Sum: 3.7]
[Termination (ms): Min: 0.0, Avg: 0.1, Max: 0.1, Diff: 0.1, Sum: 0.6]
[GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.3]
[GC Worker Total (ms): Min: 0.5, Avg: 0.8, Max: 1.0, Diff: 0.5, Sum: 6.6]
[GC Worker End (ms): Min: 121.0, Avg: 121.1, Max: 121.1, Diff: 0.1]
[Code Root Fixup: 0.0 ms]
[Code Root Migration: 0.0 ms]
[Clear CT: 0.1 ms]
[Other: 0.3 ms]
[Choose CSet: 0.0 ms]
[Ref Proc: 0.2 ms]
[Ref Enq: 0.0 ms]
[Free CSet: 0.0 ms]
[Eden: 1024.0K(10.0M)->0.0B(9216.0K) Survivors: 0.0B->1024.0K Heap: 6588.3K(20.0M)->6560.0K(20.0M)]
[Times: user=0.01 sys=0.01, real=0.00 secs]
[GC concurrent-root-region-scan-start] 第一阶段开始,初始标记
[GC concurrent-root-region-scan-end, 0.0002720 secs]初始标记完毕
[GC concurrent-mark-start] 并发标记
[GC concurrent-mark-end, 0.0000430 secs]
[GC remark [GC ref-proc, 0.0000610 secs], 0.0005240 secs] 重新标记
[Times: user=0.00 sys=0.00, real=0.01 secs]
[GC cleanup 10M->10M(20M), 0.0004140 secs] 筛选回收,就是清理
[Times: user=0.00 sys=0.00, real=0.00 secs]
Heap
garbage-first heap total 20480K, used 10656K [0x00000007f9a00000, 0x00000007fae00000, 0x00000007fae00000)
region size 1024K, 2 young (2048K), 1 survivors (1024K)
compacting perm gen total 20480K, used 2614K [0x00000007fae00000, 0x00000007fc200000, 0x0000000800000000)
the space 20480K, 12% used [0x00000007fae00000, 0x00000007fb08d840, 0x00000007fb08da00, 0x00000007fc200000)
No shared spaces configured.
其实我也知道这样测G1什么也测不出什么特性来,我就是好奇。。。玩玩~
首先,发现G1的时间很棒哎~其他的都是0.004.。。G1:0.001
region size 1024K