JVM--基础--13--内存分配策略--空间分配担保

JVM–基础–13–内存分配策略–空间分配担保


1、空间分配担保

  • 空间担保分配是指在发生Minor GC之前
  • 只要老年代的连续空间 大于 新生代对象总大小或者历次晋升的平均大小 就会进行Minor GC,否则将进行Full GC。

2、测试

2.1、代码

测试jdk7

public class Test {
    private static final int _1MB = 1024 * 1024;

  //参数
  //-verbose:gc
  //-Xms20M
  //-Xmx20M
  //-Xmn10M
  //-XX:+PrintGCDetails
  //-XX:SurvivorRatio=8
  //-XX:MaxTenuringThreshold=15     
  //-XX:+PrintTenuringDistribution   
  //-XX:+UseSerialGC
    public static void main(String[] args) {
    	 byte[] allocation1, allocation2, allocation3,
    	 allocation4;  
    	 
    	  allocation1 = new byte[2 * _1MB];  
    	  allocation2 = new byte[2 * _1MB];  
    	  allocation3 = new byte[2 * _1MB];  
    	  
    	  allocation4 = new byte[4 * _1MB];  
    	  
      
    }
}




2.1、日志

 
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option HandlePromotionFailure; support was removed in 6.0_24
[GC[DefNew
Desired survivor size 524288 bytes, new threshold 15 (max 15)
- age   1:     478760 bytes,     478760 total
: 6815K->467K(9216K), 0.0091874 secs] 6815K->6611K(19456K), 0.0092695 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] 
Heap
 def new generation   total 9216K, used 5055K [0x00000000f9a00000, 0x00000000fa400000, 0x00000000fa400000)
  eden space 8192K,  56% used [0x00000000f9a00000, 0x00000000f9e7af60, 0x00000000fa200000)
  from space 1024K,  45% used [0x00000000fa300000, 0x00000000fa374e28, 0x00000000fa400000)
  to   space 1024K,   0% used [0x00000000fa200000, 0x00000000fa200000, 0x00000000fa300000)
 tenured generation   total 10240K, used 6144K [0x00000000fa400000, 0x00000000fae00000, 0x00000000fae00000)
   the space 10240K,  60% used [0x00000000fa400000, 0x00000000faa00030, 0x00000000faa00200, 0x00000000fae00000)
 compacting perm gen  total 21248K, used 2540K [0x00000000fae00000, 0x00000000fc2c0000, 0x0000000100000000)
   the space 21248K,  11% used [0x00000000fae00000, 0x00000000fb07b350, 0x00000000fb07b400, 0x00000000fc2c0000)
No shared spaces configured.

3、分析



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值