一、vm参数
-Xms20M
-Xmx20M
-Xmn10M
-XX:+PrintGCDetails
-XX:+PrintTenuringDistribution
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC
-verbose:GC
二、代码:
package cn.edu.tju.test;
public class GcTest06 {
public static void main(String[] args) {
int size = 1024 * 1024;
byte[] b1 = new byte[4* size];
System.out.println("after allocating b1......");
byte[] b2 = new byte[4* size];
System.out.println("after allocating b2......");
byte[] b3 = new byte[4* size];
System.out.println("after allocating b3......");
byte[] b4 = new byte[2* size];
System.out.println("after allocating b4......");
}
}
三、执行结果: