GC日志学习

GC日志

Minor GC

  • 代码
/**
 * @author yanyugang
 * @description
 *  -Xms20M -Xmx20M 设置Java堆大小为20MB
 *  -Xmn10M 设置10MB分配给新生代  则剩下的10MB分配给老年代
 *  -XX:+PrintGCDetails 打印内存回收日志
 *  -XX:SurvivorRatio=8 设置新生代的Eden区和一个Survivor区的空间比例是8:1
 * @date 2019-06-26 8:21
 */
public class TestMinorGC {
    private static final int _1M=1024*1024;

    /**
     * VM Args: -verbose:gc -Xms20M -Xmx20M -Xmn10M -XX:+PrintGCDetails -XX:SurvivorRatio=8
     */
    public static void testAllocation(){
        byte[] allocation1,allocation2,allocation3,allocation4;
        allocation1=new byte[2*_1M];
        allocation2=new byte[2*_1M];
        allocation3=new byte[2*_1M];
        // 出现一次Minor GC
        allocation4=new byte[4*_1M];
    }

    public static void main(String[] args){
        testAllocation();
    }
}
  • 打印GC日志(采用的是Parallel Scavenge+Parallel Old回收组合)
[GC (Allocation Failure) [PSYoungGen: 7228K->1000K(9216K)] 7228K->5104K(19456K), 0.0043250 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
Heap
 PSYoungGen      total 9216K, used 7466K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)
  eden space 8192K, 78% used [0x00000000ff600000,0x00000000ffc509c0,0x00000000ffe00000)
  from space 1024K, 97% used [0x00000000ffe00000,0x00000000ffefa020,0x00000000fff00000)
  to   space 1024K, 0% used [0x00000000fff00000,0x00000000fff00000,0x0000000100000000)
 ParOldGen       total 10240K, used 4104K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)
  object space 10240K, 40% used [0x00000000fec00000,0x00000000ff002020,0x00000000ff600000)
 Metaspace       used 3383K, capacity 4496K, committed 4864K, reserved 1056768K
  class space    used 373K, capacity 388K, committed 512K, reserved 1048576K
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值