GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PassJava-Learning/docs/88.Interview/其他.md at master · Luo4507/PassJava-Learning

Expand file tree

/

其他.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
27 lines (13 loc) · 854 Bytes
/

其他.md

Copy path

File metadata and controls

27 lines (13 loc) · 854 Bytes
Raw
Copy raw file
Download raw file
Edit and raw actions

CPU 100% 了,怎么排查、定位和解决?

(1)定位耗费 CPU 的进程

top -c 显示进程列表,然后输入 P,按照 CPU 使用率最高的排序。

就可以拿到是哪个进程占用 CPU 最高了,把 进程 id 先记下来。

(2)定位耗费 CPU 的线程

top -Hp <进程 id> 拿到线程 id

(3)将线程 id 转为 16 进制

printf “%x\n” ,把线程 pid 转为16进制,比如 0xf58

(4)定位哪段代码导致的 CPU 太高了

jstack | grep -A 10 0xf58 查看线程的堆栈日志

这个命令会打印出哪个类,哪个方法导致 CPU 100% 的问题。然后把代码拉出来看下,修复解决。

整体思路:

找 CPU 过高的的进程,找进程的线程,然后通过 jstack 命令可以迅速找出线程中哪段代码造成了死锁问题或死循环的问题。

You are visitor 01402809 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.