一、jvm参数
-Xms100M -Xmx100M -Xmn30M -XX:+PrintGCDetails -XX:MaxTenuringThreshold=8 -XX:+PrintTenuringDistribution
二、代码
package cn.edu.tju.test;
public class GcTest04 {
public static void main(String[] args) {
int size = 1024* 1024;
byte[] b1 = new byte[10*size];
byte[] b2 = new byte[10*size];
byte[] b3 = new byte[10*size];
byte[] b4 = new byte[10*size];
byte[] b5 = new byte[10*size];
System.out.println("finished......");
}
}
三、执行结果
从结果看,新生代对象最大年龄为8 ,实际为7时就将其晋升到了老年代