• JVM 备忘录


    Java 虚拟机

    GC 日志相关配置

    -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -Xloggc:./gc.log
    
    • -XX:+PrintGC 输出GC日志
    • -XX:+PrintGCDetails 输出GC的详细日志
    • -XX:+PrintGCTimeStamps 输出GC的时间戳(以基准时间的形式)
    • -XX:+PrintGCDateStamps 输出GC的时间戳(以日期的形式,如 2013-05-04T21:53:59.234+0800)
    • -XX:+PrintHeapAtGC 在进行GC的前后打印出堆的信息
    • -Xloggc:./gc.log 日志文件的输出路径
    Java HotSpot(TM) 64-Bit Server VM (25.121-b13) for windows-amd64 JRE (1.8.0_121-b13), built on Dec 12 2016 18:21:36 by "java_re" with MS VC++ 10.0 (VS2010)
    Memory: 4k page, physical 16599008k(3716028k free), swap 27331352k(3936160k free)
    CommandLine flags: -XX:InitialHeapSize=20971520 -XX:MaxHeapSize=20971520 -XX:MaxNewSize=10485760 -XX:NewSize=10485760 -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -XX:SurvivorRatio=8 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC 
    {Heap before GC invocations=1 (full 0):
     PSYoungGen      total 9216K, used 6307K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)
      eden space 8192K, 76% used [0x00000000ff600000,0x00000000ffc28ce8,0x00000000ffe00000)
      from space 1024K, 0% used [0x00000000fff00000,0x00000000fff00000,0x0000000100000000)
      to   space 1024K, 0% used [0x00000000ffe00000,0x00000000ffe00000,0x00000000fff00000)
     ParOldGen       total 10240K, used 0K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)
      object space 10240K, 0% used [0x00000000fec00000,0x00000000fec00000,0x00000000ff600000)
     Metaspace       used 3477K, capacity 4496K, committed 4864K, reserved 1056768K
      class space    used 384K, capacity 388K, committed 512K, reserved 1048576K
    2019-11-28T09:53:34.265+0800: 0.123: [GC (Allocation Failure) [PSYoungGen: 6307K->776K(9216K)] 6307K->4880K(19456K), 0.0022355 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
    Heap after GC invocations=1 (full 0):
     PSYoungGen      total 9216K, used 776K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)
      eden space 8192K, 0% used [0x00000000ff600000,0x00000000ff600000,0x00000000ffe00000)
      from space 1024K, 75% used [0x00000000ffe00000,0x00000000ffec2020,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 3477K, capacity 4496K, committed 4864K, reserved 1056768K
      class space    used 384K, capacity 388K, committed 512K, reserved 1048576K
    }
    Heap
     PSYoungGen      total 9216K, used 7241K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)
      eden space 8192K, 78% used [0x00000000ff600000,0x00000000ffc50650,0x00000000ffe00000)
      from space 1024K, 75% used [0x00000000ffe00000,0x00000000ffec2020,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 3499K, capacity 4498K, committed 4864K, reserved 1056768K
      class space    used 387K, capacity 390K, committed 512K, reserved 1048576K
    
    

    JVM常用内存设置

    参考: Oracle Javase8 Doc

    -Xms1024M -Xmx1024M -Xmn512M -Xss2M -XX:SurvivorRatio=8 -XX:MaxMetaspaceSize=256M
    
    • -Xms1024M 堆空间设置最小空间限制,一般要大于程序启动时占用内存大小;
    • -Xmx1024M 设置堆空间的最大可申请上限,和-XX:MaxHeapSize功能相同,一般-Xms 和-Xmx 设置成相同值;
    • -Xmn512M 设置堆空间中的“年轻代”的初始值和最大值大小; 如果设置的过小,会导致频繁的Minor GC,如果设置的过大,会累积成一次Full GC 导致单次GC时间过长;官方推荐的年轻代大小是 堆空间的四分之一到二分之一;
    • -Xss2M 设置虚拟机栈(线程栈)的最大值,功能和-XX:ThreadStackSize相同,一般默认1MB左右
    • -XX:SurvivorRatio=8 设置eden区和survivor区的比率,默认设置为8,则Eden80%,From_Survivor10%,To_Survivor10%
    • -XX:MaxMetaspaceSize=256M 设置元空间在直接内存中的最大值;默认是不限制的,宿主机有多大剩余空间,就可以申请到多少空间。

    JVM默认参数配置

    java -XX:+PrintFlagsFinal -version
    
  • 相关阅读:
    TP5.0 excel 导入导出
    整理关于web项目如何防止CSRF和XSS攻击的方法
    vue ajax获取数据的时候,如何保证传递参数的安全或者说如何保护api的安全
    vue.js打包后,接口安全问题
    JSON API免费接口
    tp5 $_ENV获取不到数据
    java cannot find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
    如何查找到文件以后,带目录一起拷贝到新的目录? cp --parents source destination
    台湾各个大学硕博论文链接,很全,有的可以全文下载。
    delete
  • 原文地址:https://www.cnblogs.com/IC1101/p/11945000.html
Copyright © 2020-2023  润新知