package com.cn.jvm;
/**
* 描述:查看jvm gc
*
* jvm params:-verbose:gc -Xms20M -Xmx20M -Xmn10M -XX:SurvivorRatio=8 -XX:+PrintGCDetails
* -verbose:gc -Xms20M -Xmx20M -Xmn10M -XX:SurvivorRatio=8 -XX:+PrintGCDateStamps -XX:+PrintGCDetails -Xloggc:G:\study_hard_myGIT\javaSE_test\src\com\cn\jvm\logs\gc.log
* @author chen_q_i@163.com
* 2017/11/7 : 15:44.
* @version : 1.0
*/
public class TestAllLocation {
private static final int ONE_MB=1024*1024;
public static void testAllLocatonMethod(){
byte[] allLocation,allLocation1,allLocation2,allLocation3;
allLocation= new byte[2*ONE_MB];
allLocation1= new byte[2*ONE_MB];
allLocation2= new byte[2*ONE_MB];
//GC
allLocation3= new byte[4*ONE_MB];
}
public static void main(String[] args) {
for (int i = 0; i <3 ; i++) {
testAllLocatonMethod();
}
}
}
image.png
image.png
运行结果
image.png《深入理解Java虚拟机JVM高级特性与最佳实践》67页测试例
网友评论