• 查看运行中的Java其配置的堆大小


    一、背景

    有题目中的需求,也不是空穴来风;前一阵给公司搭建了一个持续集成服务器,Jenkins。最近发现,运行一段时间后,就变慢了。

    随便一个操作,cpu就飙高了。然后就思考会不会是内存不够用,频繁GC导致的呢?

    Jenkins是个war包,我直接放在tomcat运行的。所以,我需要查看下,当前运行的这个tomcat的堆大小。

    二、步骤

    [root@pas jenkins-apache-tomcat-8.5.28]# jmap -heap 90170
    Attaching to process ID 90170, please wait...
    Debugger attached successfully.
    Server compiler detected.
    JVM version is 25.161-b12
    
    using thread-local object allocation.
    Parallel GC with 8 thread(s)
    
    Heap Configuration:
       MinHeapFreeRatio         = 0
       MaxHeapFreeRatio         = 100
       MaxHeapSize              = 4160749568 (3968.0MB)  -----------堆的最大容量
       NewSize                  = 86507520 (82.5MB)
       MaxNewSize               = 1386741760 (1322.5MB) 
       OldSize                  = 173539328 (165.5MB)
       NewRatio                 = 2
       SurvivorRatio            = 8
       MetaspaceSize            = 21807104 (20.796875MB)
       CompressedClassSpaceSize = 1073741824 (1024.0MB)
       MaxMetaspaceSize         = 17592186044415 MB
       G1HeapRegionSize         = 0 (0.0MB)
    
    Heap Usage:
    PS Young Generation
    Eden Space:
       capacity = 1306001408 (1245.5MB)
       used     = 1123777200 (1071.7174530029297MB)
       free     = 182224208 (173.7825469970703MB)
       86.04716603797107% used
    From Space:
       capacity = 37748736 (36.0MB)
       used     = 17255448 (16.456077575683594MB)
       free     = 20493288 (19.543922424316406MB)
       45.711326599121094% used
    To Space:
       capacity = 37224448 (35.5MB)
       used     = 0 (0.0MB)
       free     = 37224448 (35.5MB)
       0.0% used
    PS Old Generation
       capacity = 212336640 (202.5MB)
       used     = 90248224 (86.06741333007812MB)
       free     = 122088416 (116.43258666992188MB)
       42.50242633584105% used
    
    44622 interned Strings occupying 4789016 bytes.

    具体的字段意思,我查阅了oracle的官方资料,如下,但也没有看到具体解释,只能慢慢探索了:

    https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr014.html#BABJIIIH

    可以看到,上面的tomcat的最大堆容量还是很大的,当然,我们自己没有配置过,应该是JVM根据机器的物理内存大小,自动计算的。

  • 相关阅读:
    最大组合的数 A
    2106. 求对称字符串的最大长度 A
    内存分配 A
    242. 子串匹配 A
    【LeetCode 1055】形成字符串的最短路径 A
    给定差值的组合 A
    1791 设备编号 A
    最长的指定瑕疵度的元音子串 A
    1898. 【认证试题】遥控小车 A
    1792 服务器集群网络延迟 A
  • 原文地址:https://www.cnblogs.com/grey-wolf/p/9224137.html
Copyright © 2020-2023  润新知