返回列表 回复 发帖

关于Java程序性能优化书上的JVM FULL GC的问题

JVM参数:
-XX:+PrintGCDetails  -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=15 -Xms40M -Xmx40M -Xmn20M

public static void main(String[] args) {
// TODO Auto-generated method stub
byte[] b1=new byte[1024*1024/2];
byte[] b2=new byte[1024*1024*8];
b2=null;
b2=new byte[1024*1024*8];
System.gc();
}
打印信息:

[GC [DefNew: 9031K->651K(18432K), 0.0012066 secs] 9031K->651K(38912K), 0.0012309 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[Full GC (System) [Tenured: 0K->8843K(20480K), 0.0051831 secs] 8843K->8843K(38912K), [Perm : 2053K->2053K(12288K)], 0.0052230 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
Heap
def new generation   total 18432K, used 327K [0x03200000, 0x04600000, 0x04600000)
  eden space 16384K,   2% used [0x03200000, 0x03251f20, 0x04200000)
  from space 2048K,   0% used [0x04400000, 0x04400000, 0x04600000)
  to   space 2048K,   0% used [0x04200000, 0x04200000, 0x04400000)
tenured generation   total 20480K, used 8843K [0x04600000, 0x05a00000, 0x05a00000)
   the space 20480K,  43% used [0x04600000, 0x04ea2e80, 0x04ea3000, 0x05a00000)
compacting perm gen  total 12288K, used 2059K [0x05a00000, 0x06600000, 0x09a00000)
   the space 12288K,  16% used [0x05a00000, 0x05c02d58, 0x05c02e00, 0x06600000)
No shared spaces configured.

为什么所有对象都到老年代去了,尤其是b1这个对象?一直想不通这个问题,请大家帮忙一下,谢谢啦!
返回列表