zoukankan      html  css  js  c++  java
  • System.gc()日志分析

    打开日志:运行配置---XX:+PrintGCDetails

    示例程序:

    package com.test;
    
    public class Test
    {
        private Object instance = null;
        private String str;
        
        private static final int _1MB = 1024 * 1024;
        /** 这个成员属性唯一的作用就是占用一点内存 */
        private byte[] bigSize = new byte[2 * _1MB];
        
        public static void main(String[] args)
        {
            Test objectA = new Test();
            objectA.str = objectA.bigSize.toString();
            Test objectB = new Test();
            objectB.str = objectB.bigSize.toString();
            objectA.instance = objectA;
            objectB.instance = objectB;
            
            objectA = null;
            objectB = null;
            
            System.gc();
        }
    }

    打印:

    [GC [PSYoungGen: 5980K->584K(229376K)] 5980K->584K(491520K), 0.0020351 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
    [Full GC [PSYoungGen: 584K->0K(229376K)] [ParOldGen: 0K->465K(262144K)] 584K->465K(491520K) [PSPermGen: 2573K->2572K(131072K)], 0.0116565 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] 
    Heap
     PSYoungGen      total 229376K, used 7864K [0x00000000f0000000, 0x0000000100000000, 0x0000000100000000)
      eden space 196608K, 4% used [0x00000000f0000000,0x00000000f07ae210,0x00000000fc000000)
      from space 32768K, 0% used [0x00000000fc000000,0x00000000fc000000,0x00000000fe000000)
      to   space 32768K, 0% used [0x00000000fe000000,0x00000000fe000000,0x0000000100000000)
     ParOldGen       total 262144K, used 465K [0x00000000e0000000, 0x00000000f0000000, 0x00000000f0000000)
      object space 262144K, 0% used [0x00000000e0000000,0x00000000e00744a0,0x00000000f0000000)
     PSPermGen       total 131072K, used 2579K [0x00000000d0000000, 0x00000000d8000000, 0x00000000e0000000)
      object space 131072K, 1% used [0x00000000d0000000,0x00000000d0284e98,0x00000000d8000000)

    注释掉objectA = null; 和 objectB = null;

    打印:

    [GC [PSYoungGen: 9912K->4680K(229376K)] 9912K->4680K(491520K), 0.0092221 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] 
    [Full GC [PSYoungGen: 4680K->0K(229376K)] [ParOldGen: 0K->4561K(262144K)] 4680K->4561K(491520K) [PSPermGen: 2573K->2572K(131072K)], 0.0155152 secs] [Times: user=0.05 sys=0.00, real=0.02 secs] 
    Heap
     PSYoungGen      total 229376K, used 5898K [0x00000000f0000000, 0x0000000100000000, 0x0000000100000000)
      eden space 196608K, 3% used [0x00000000f0000000,0x00000000f05c29c0,0x00000000fc000000)
      from space 32768K, 0% used [0x00000000fc000000,0x00000000fc000000,0x00000000fe000000)
      to   space 32768K, 0% used [0x00000000fe000000,0x00000000fe000000,0x0000000100000000)
     ParOldGen       total 262144K, used 4561K [0x00000000e0000000, 0x00000000f0000000, 0x00000000f0000000)
      object space 262144K, 1% used [0x00000000e0000000,0x00000000e0474570,0x00000000f0000000)
     PSPermGen       total 131072K, used 2579K [0x00000000d0000000, 0x00000000d8000000, 0x00000000e0000000)
      object space 131072K, 1% used [0x00000000d0000000,0x00000000d0284e90,0x00000000d8000000)

    日志信息解释:

    YoungGC日志解释如下

    FullGC

  • 相关阅读:
    2-sat问题,输出方案,几种方法(赵爽的论文染色解法+其完全改进版)浅析 / POJ3683
    hdu 4587 2013南京邀请赛B题/ / 求割点后连通分量数变形。
    最小费用最大流粗解 poj2516
    hdu3078 建层次树+在线LCA算法+排序
    hdu 3594 Cactus /uva 10510 仙人掌图判定
    有向图最小路径覆盖方法浅析、证明 //hdu 3861
    hdu 1827 有向图缩点看度数
    条件转化,2-sat BZOJ 1997
    2-sat基础题 BZOJ 1823
    2-sat 分类讨论 UVALIVE 3713
  • 原文地址:https://www.cnblogs.com/x-jingxin/p/9767473.html
Copyright © 2011-2022 走看看