美文网首页
jvm相关信息查看

jvm相关信息查看

作者: 风吹路过的云 | 来源:发表于2020-07-17 11:14 被阅读0次

    1 查看某进程的线程数量

    top -H -p {pid}
    

    top之后,界面类似如下,Threads: 309 total,即是线程数

    Threads: 309 total,   1 running, 308 sleeping,   0 stopped,   0 zombie
    %Cpu(s):  4.6 us,  4.2 sy,  0.0 ni, 90.9 id,  0.1 wa,  0.0 hi,  0.2 si,  0.0 st
    KiB Mem : 32778364 total,   700616 free, 27804168 used,  4273580 buff/cache
    KiB Swap:        0 total,        0 free,        0 used.  4344696 avail Mem
    
    
      PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND                                                                
      200 root      20   0   14.0g   5.0g   8680 R  4.7 16.1 138:43.37 java                                                                   
      115 root      20   0   14.0g   5.0g   8680 S  0.7 16.1  15:26.11 java                                                                   
      121 root      20   0   14.0g   5.0g   8680 S  0.7 16.1  15:26.44 java                                                                   
      124 root      20   0   14.0g   5.0g   8680 S  0.7 16.1  15:21.59 java                                                                   
      127 root      20   0   14.0g   5.0g   8680 S  0.7 16.1  15:26.56 java                                                                   
      145 root      20   0   14.0g   5.0g   8680 S  0.7 16.1  15:26.50 java                                                                   
      154 root      20   0   14.0g   5.0g   8680 S  0.7 16.1  15:26.50 java                                                                   
      157 root      20   0   14.0g   5.0g   8680 S  0.7 16.1  15:29.32 java                                                                   
      103 root      20   0   14.0g   5.0g   8680 S  0.3 16.1  15:26.32 java      
    

    2 java线程数

    jstack {pid} | grep "tid" | wc -l
    pid为进程id
    

    3 查看gc情况

    jstat -gcutil {pid} 5000
    5000表示5秒更新一次数据
    百分比
    [root@144 ~]# jstat -gcutil 20923 5000
      S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT   
      0.00  28.05  90.94  48.34  95.98  93.86     73    1.274     5    0.648    1.922
      0.00  28.05  91.22  48.34  95.98  93.86     73    1.274     5    0.648    1.922
      0.00  28.05  91.22  48.34  95.98  93.86     73    1.274     5    0.648    1.922
      0.00  28.05  91.41  48.34  95.98  93.86     73    1.274     5    0.648    1.922
      0.00  28.05  91.42  48.34  95.98  93.86     73    1.274     5    0.648    1.922
      0.00  28.05  91.69  48.34  95.98  93.86     73    1.274     5    0.648    1.922
      0.00  28.05  91.82  48.34  95.98  93.86     73    1.274     5    0.648    1.922
      0.00  28.05  92.07  48.34  95.98  93.86     73    1.274     5    0.648    1.922
      0.00  28.05  92.11  48.34  95.98  93.86     73    1.274     5    0.648    1.922
    
    jstat -gc {pid} 5000
    比较详细的数据
    [root@144 ~]# jstat -gc 20923 5000
    S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT   
    3072.0 3072.0 1588.9  0.0   156672.0 146168.1  124416.0   61038.2   72384.0 69598.7 7936.0 7464.6     94    1.410   5      0.648    2.058
    3072.0 3072.0 1588.9  0.0   156672.0 146414.2  124416.0   61038.2   72384.0 69598.7 7936.0 7464.6     94    1.410   5      0.648    2.058
    3072.0 3072.0 1588.9  0.0   156672.0 146753.3  124416.0   61038.2   72384.0 69598.7 7936.0 7464.6     94    1.410   5      0.648    2.058
    3072.0 3072.0 1588.9  0.0   156672.0 146843.5  124416.0   61038.2   72384.0 69598.7 7936.0 7464.6     94    1.410   5      0.648    2.058
    

    另外

    查看哪几个进程内存占用最高:top -c,输入大写M,以内存使用率从高到低排序
    假设占用内存最高的Java进程PID为16818
    确认是不是内存本身分配过小:jmap -heap 16818
    找到最耗内存的对象:jmap -histo 16818 (带上:live则表示先进行一次FGC再统计,如jmap -histo:live 16818)
    导出内存转储快照:jmap -dump:live,format=b,file=heap.bin 16818 (使用Eclipse mat分析)
    统计进程打开的句柄数:ls /proc/16818/fd |wc -l
    统计进程打开的线程数:ls /proc/16818/task |wc -l
    

    参考资料:
    https://www.analysys.cn/article/detail/20019016
    https://blog.csdn.net/u012167045/article/details/57426640
    https://blog.51cto.com/kusorz/1962548

    相关文章

      网友评论

          本文标题:jvm相关信息查看

          本文链接:https://www.haomeiwen.com/subject/vzzwhktx.html