GC之十:GC (Allocation Failure)

1、[GC (Allocation Failure) AF

见:http://stackoverflow.com/questions/28342736/java-gc-allocation-failure

示例代码:

package dxz.jvm.part3;

import java.util.concurrent.TimeUnit;

/**
 * @VM args:-verbose:gc -Xms20m -Xmx20m -Xmn10m -XX:SurvivorRatio=8
 * -XX:PretenureSizeThreshold=3145728
 * 3145728=3m,所以下面的4m直接分配到老年代中
*
@author lenovo * */ public class GCTest { private static final int _1MB = 1024 * 1024; public static void testPretenureSizeThreshold() { byte[] allocation; allocation = new byte[4 * _1MB]; } public static void main(String[] args) throws InterruptedException { TimeUnit.SECONDS.sleep(30); testPretenureSizeThreshold(); } }

结果:

[GC (Allocation Failure) [PSYoungGen: 8192K->1000K(9216K)] 8192K->2064K(19456K), 0.0141635 secs] [Times: user=0.05 sys=0.00, real=0.01 secs] 
Heap
 PSYoungGen      total 9216K, used 7743K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)
  eden space 8192K, 82% used [0x00000000ff600000,0x00000000ffc95e98,0x00000000ffe00000)
  from space 1024K, 97% used [0x00000000ffe00000,0x00000000ffefa020,0x00000000fff00000)
  to   space 1024K, 0% used [0x00000000fff00000,0x00000000fff00000,0x0000000100000000)
 ParOldGen       total 10240K, used 1064K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)
  object space 10240K, 10% used [0x00000000fec00000,0x00000000fed0a020,0x00000000ff600000)
 Metaspace       used 8554K, capacity 8862K, committed 9088K, reserved 1056768K
  class space    used 1025K, capacity 1115K, committed 1152K, reserved 1048576K

 

 

posted on 2013-01-27 15:51  duanxz  阅读(5571)  评论(1编辑  收藏  举报