public static void main(String[] args) {
byte[] a1,a2,a3;
a1 = new byte[4 * _1M];
a2 = new byte[4 * _1M];
System.out.println("1");
a3 = new byte[4 * _1M];
System.out.println("2");
a3 = null;
System.out.println("3");
a3 = new byte[4 * _1M];
System.out.println("4");
}
JVM配置:-verbose:gc -Xms20m -Xmx20m -Xmn10m -XX:+PrintGCDetails -XX:SurvivorRatio=8 -XX:+UseSerialGC
控制台输出:
[GC (Allocation Failure) [DefNew: 5079K->525K(9216K), 0.0024421 secs] 5079K->4621K(19456K), 0.0024969 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
1
[GC (Allocation Failure) [DefNew: 4779K->0K(9216K), 0.0020170 secs] 8875K->8716K(19456K), 0.0020318 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
2
3
[GC (Allocation Failure) [DefNew: 4255K->4255K(9216K), 0.0000074 secs][Tenured: 8716K->8717K(10240K), 0.0010752 secs] 12972K->8717K(19456K),
[Metaspace: 2665K->2665K(1056768K)], 0.0011070 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
4
Heap
def new generation total 9216K, used 4418K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)
eden space 8192K, 53% used [0x00000000fec00000, 0x00000000ff050b68, 0x00000000ff400000)
from space 1024K, 0% used [0x00000000ff400000, 0x00000000ff400000, 0x00000000ff500000)
to space 1024K, 0% used [0x00000000ff500000, 0x00000000ff500000, 0x00000000ff600000)
tenured generation total 10240K, used 8717K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)
the space 10240K, 85% used [0x00000000ff600000, 0x00000000ffe83420, 0x00000000ffe83600, 0x0000000100000000)
Metaspace used 2672K, capacity 4486K, committed 4864K, reserved 1056768K
class space used 288K, capacity 386K, committed 512K, reserved 1048576K
请问:3-4中间的GC为什么DefNew和Tenured都没有变化呢?那新增的内存放哪里啦?