import java.util.ArrayList;
public class Demo {
public static void main(String[] args) {
for (String arg : args) {
System.out.println(arg);
}
ArrayList<Object> objects = new ArrayList<>();
for (int i = 0; i < 500; i++) {
byte[] bytes = new byte[1024 * 100];
objects.add(bytes);
}
}
}
-Xms60m -Xmx60m -XX:+PrintGCDetails
JDK 7
JDK8
大对象直接放进 old区 ,而不是先yonugGC
package com.rs.testfield.jvm.gc;
public class Demo {
private static final int _1MB = 1024 * 1024;
//-Xms60m -Xmx60m -XX:SurvivorRatio=8 -XX:+PrintGCDetails -Xloggc:./logs/gc.log
public static void testAllocation(){
byte[] allocation1,allocation2,allocation3,allocation4;
allocation1 = new byte[2* _1MB];
allocation2 = new byte[2* _1MB];
allocation3 = new byte[1* _1MB];
allocation4 = new byte[4* _1MB];
}
public static void main(String[] args) {
testAllocation();
}
}