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

  • 相关阅读:
    python+selenium初学者常见问题处理
    pycharm的这些配置,你都知道吗
    巧用浏览器F12调试器定位系统前后端bug
    dsu + lca
    indeed2017校招在线编程题(网测)三
    rolling hash
    ac自动机
    indeed 第二次笔试题
    vmware以及schlumberger题解
    2017 google Round C APAC Test 题解
  • 原文地址:https://www.cnblogs.com/x-jingxin/p/9767473.html
Copyright © 2011-2022 走看看