【JVM】9_大对象直接进入老年代

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013295276/article/details/78459430
/**
 * VM参数 :
 * -verbose:gc
 * -Xms20M
 * -Xmx20M
 * -Xmn10M
 * -XX:+PrintGCDetails
 * -XX:SurvivorRatio=8
 * -XX:PretenureSizeThreshold=3145728       //对象如果大于或等于此值,会直接分配到老年代里
 * -XX:+UseSerialGC                         //使用Serial收集器(使用其他收集器不一定行)
 */
public class Main {

    private static final int _1MB = 1024 * 1024;

    public static void main(String[] args) {
        byte[] bigBytes = new byte[4 * _1MB];
    }
}

运行结果:

Heap
 def new generation   total 9216K, used 2318K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)
  eden space 8192K,  28% used [0x00000000fec00000, 0x00000000fee43bd0, 0x00000000ff400000)
  from space 1024K,   0% used [0x00000000ff400000, 0x00000000ff400000, 0x00000000ff500000)
  to   space 1024K,   0% used [0x00000000ff500000, 0x00000000ff500000, 0x00000000ff600000)
 tenured generation   total 10240K, used 4096K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)
   the space 10240K,  40% used [0x00000000ff600000, 0x00000000ffa00010, 0x00000000ffa00200, 0x0000000100000000)
 Metaspace       used 3263K, capacity 4496K, committed 4864K, reserved 1056768K
  class space    used 357K, capacity 388K, committed 512K, reserved 1048576K

可以看到tenured generation   total 10240K, used 4096K,4M的内存的确直接被分配到老年代里了。
阅读更多
换一批

没有更多推荐了,返回首页