java进程CPU高分析
2024-10-19 13:34:22
JVM导致系统CPU高的常见场景:
内存不足,JVM gc频繁,一般会伴随OOM
JVM某个线程死循环或者递归调用
定位和解决
1.内存不足,gc频繁可参考我的这遍文章解决。https://blog.csdn.net/moranzi1/article/details/88670204
2.JVM某个线程死循环或者递归调用。这种情况关键是找到导致CPU高的线程。然后根据具体线程具体分析为什么该线程会导致CPU高。需要线程的步骤如下。
top——命令查看cpu高的进程
[root@iZwz9gs2zseivevv1k5vnkZ syp]# top
top - :: up days, :, users, load average: 4.59, 4.16, 3.26
Tasks: total, running, sleeping, stopped, zombie
%Cpu(s): 84.1 us, 4.5 sy, 0.0 ni, 10.8 id, 0.1 wa, 0.0 hi, 0.6 si, 0.0 st
KiB Mem : total, free, used, buff/cache
KiB Swap: total, free, used. avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
root S 293.0 6.0 :23.05 java
root S 15.9 3.2 : java
root S 12.0 5.0 : java
root S 2.3 5.3 :16.27 java
root S 2.0 4.8 :26.20 java
root - S 2.0 0.1 :57.96 AliYunDun
ps aux | grep PID——命令查看具体进程信息
ps -mp pid -o THREAD,tid,time——命令查看进程线程信息,找到导致CPU高的线程TID
[root@iZwz9gs2zseivevv1k5vnkZ syp]# ps -mp -o THREAD,tid,time
USER %CPU PRI SCNT WCHAN USER SYSTEM TID TIME
root 22.7 - - - - - - ::
root 0.0 - futex_ - - ::
root 0.1 - futex_ - - ::
root 4.6 - - - - ::
root 4.6 - - - - ::
root 4.6 - - - - ::
root 4.6 - - - - ::
root 1.2 - futex_ - - ::
printf "%x\n" tid——命令转换线程为16进制格式
[root@iZwz9gs2zseivevv1k5vnkZ syp]# printf “%x\n”
“2f4dn” [root@iZwz9gs2zseivevv1k5vnkZ syp]# printf “%x\n”
“2f4en” [root@iZwz9gs2zseivevv1k5vnkZ syp]# printf “%x\n”
“2f4fn” [root@iZwz9gs2zseivevv1k5vnkZ syp]# printf “%x\n”
“2f50n”
jstack pid |grep tid -A 30——命令查看线程信息,定位到具体线程
[root@iZwz9gs2zseivevv1k5vnkZ syp]# jstack | grep 2f4d -A
"GC task thread#0 (ParallelGC)" os_prio= tid=0x00007f223405e000 nid=0x2f4d runnable "GC task thread#1 (ParallelGC)" os_prio= tid=0x00007f2234060000 nid=0x2f4e runnable "GC task thread#2 (ParallelGC)" os_prio= tid=0x00007f2234061800 nid=0x2f4f runnable "GC task thread#3 (ParallelGC)" os_prio= tid=0x00007f2234063800 nid=0x2f50 runnable "VM Periodic Task Thread" os_prio= tid=0x00007f22341ed800 nid=0x2f59 waiting on condition JNI global references: [root@iZwz9gs2zseivevv1k5vnkZ syp]# jstack | grep 2f4e -A
"GC task thread#1 (ParallelGC)" os_prio= tid=0x00007f2234060000 nid=0x2f4e runnable "GC task thread#2 (ParallelGC)" os_prio= tid=0x00007f2234061800 nid=0x2f4f runnable "GC task thread#3 (ParallelGC)" os_prio= tid=0x00007f2234063800 nid=0x2f50 runnable "VM Periodic Task Thread" os_prio= tid=0x00007f22341ed800 nid=0x2f59 waiting on condition JNI global references: "GC task thread#2 (ParallelGC)" os_prio= tid=0x00007f2234061800 nid=0x2f4f runnable "GC task thread#3 (ParallelGC)" os_prio= tid=0x00007f2234063800 nid=0x2f50 runnable "VM Periodic Task Thread" os_prio= tid=0x00007f22341ed800 nid=0x2f59 waiting on condition JNI global references: [root@iZwz9gs2zseivevv1k5vnkZ syp]# jstack | grep 2f50 -A
"GC task thread#3 (ParallelGC)" os_prio= tid=0x00007f2234063800 nid=0x2f50 runnable "VM Periodic Task Thread" os_prio= tid=0x00007f22341ed800 nid=0x2f59 waiting on condition JNI global references:
参考:
https://blog.csdn.net/moranzi1/article/details/89341480
最新文章
- 浅谈WEB页面提速(前端向)
- NodeJs对Mysql封装
- Linux httpd源码编译安装
- 前端MVVM框架设计及实现(一)
- mysql explain执行计划详解
- 如何在 Ubuntu 14.04 里面配置 chroot 环境
- jquery 常用类别选择器
- 查看Nginx、apache、MySQL和PHP的编译参数
- JAVA中抽象类的一些总结
- EasyUI-页面布局
- armv8(aarch64)linux内核中flush_dcache_all函数详细分析
- rdf
- log4net使用具体解释
- cookie值的设置,获取及删除
- Windows Redis默认配置文件,Redis配置不生效解决方案
- mysql主从同步+mycat读写分离+.NET程序连接mycat代理
- 关于 AutomationProperties.Name 的一些总结
- java内部类、接口、集合框架、泛型、工具类、实现类
- TensorFlow学习笔记(UTF-8 问题解决 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte)
- Latex:入门教程
热门文章
- Pytest学习笔记(三) 在代码中运行pytest
- 【洛谷2050】 [NOI2012]美食节(费用流)
- javafx随手记录
- mysql中的utf8mb4、utf8mb4_unicode_ci、utf8mb4_general_ci的关系
- PPT:很多文字如何排版?(PPT如何美化?)
- Devops(一):CentOS7 安装Maven3.6.1详解
- DNA Sorting
- MybatisUtil工具类的作用
- .SpringIOC容器
- haproxy-负载均衡介绍