代码
package com.atguigu.java.gc;
/**
* @author Administrator
*
*/
public class GcDemo {
private static final int _1MB = 1024 * 1024;
public static void main(String[] args) {
testAllocation();
}
public static void testAllocation() {
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];
}
}
参数
-Xms20m
-Xmx20m
-Xmn10m
-XX:SurvivorRatio=8
-XX:+UseSerialGC
-XX:+PrintGCDetails
结果对比
JDK7结果图
JDK8结果图
结论
和宋红康老师jvmp198讲解的有出入,求指导