jdk1.8内存模型

代码部分
/**
 * -Xmx20m -Xms20m -Xmn2m   -XX:SurvivorRatio=2 -XX:+PrintGCDetails
 * -Xmx20m -Xms20m -Xmn7m   -XX:SurvivorRatio=2 -XX:+PrintGCDetails
 * -Xmx20m -Xms20m -Xmn15m  -XX:SurvivorRatio=8 -XX:+PrintGCDetails
 *
 * -Xmx20M -Xms20M -XX:NewRatio=2  -XX:+PrintGCDetails
 *
 * @author Geym
 */
public class NewSizeDemo {
    public static void main(String[] args) {
       byte[] b=null;
       for(int i=0;i<3;i++)
           b=new byte[1*1024*1024];
    }
}
 分析* -Xmx20m -Xms20m -Xmn7m   -XX:SurvivorRatio=2 -XX:+PrintGCDetails
 -Xmn7m代表新生代内存,一般设置为堆内存的1/3或者1/4;-XX:SurvivorRatio=2表示新生代eden:from:to=2:1:1;eden+from+to=7m
 数据先从from到to到eden到老年代
 后台打印日志
 Heap
 PSYoungGen      total 5632K, used 4822K [0x00000000ff900000, 0x0000000100000000, 0x0000000100000000)
  eden space 4096K, 80% used [0x00000000ff900000,0x00000000ffc380e8,0x00000000ffd00000)
  from space 1536K, 99% used [0x00000000ffe80000,0x00000000ffffda78,0x0000000100000000)
  to   space 1536K, 0% used [0x00000000ffd00000,0x00000000ffd00000,0x00000000ffe80000)
 ParOldGen       total 13312K, used 335K [0x00000000fec00000, 0x00000000ff900000, 0x00000000ff900000)
  object space 13312K, 2% used [0x00000000fec00000,0x00000000fec53c18,0x00000000ff900000)
 Metaspace       used 3439K, capacity 4620K, committed 4864K, reserved 1056768K
  class space    used 361K, capacity 392K, committed 512K, reserved 1048576K
Disconnected from the target VM, address: '127.0.0.1:54413', transport: 'socket'

eden:from:to=2:1:1
eden+from+to=7m
程序连续申请了3M=eden*80%+from*99%

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值