排查java程序导致cpu占用过高的问题

1.使用top命令,按住shift+C按照cpu占用比例排序展示,找到占用cpu最高的程序pid为 24062

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
24062 root 20 0 18.3g 924496 14500 S 99.0 11.5 0:00.01 java
24063 root 20 0 18.3g 924496 14500 S 0.0 11.5 0:22.24 java
24064 root 20 0 18.3g 924496 14500 S 0.0 11.5 0:08.51 java
24065 root 20 0 18.3g 924496 14500 S 0.0 11.5 0:08.46 java
24066 root 20 0 18.3g 924496 14500 S 0.0 11.5 0:08.61 java
24067 root 20 0 18.3g 924496 14500 S 0.0 11.5 0:08.54 java
24068 root 20 0 18.3g 924496 14500 S 0.0 11.5 0:08.53 java
24069 root 20 0 18.3g 924496 14500 S 0.0 11.5 0:08.54 java
24070 root 20 0 18.3g 924496 14500 S 0.0 11.5 0:08.64 java
24071 root 20 0 18.3g 924496 14500 S 0.0 11.5 0:08.67 java
24072 root 20 0 18.3g 924496 14500 S 0.0 11.5 0:08.57 java
24073 root 20 0 18.3g 924496 14500 S 0.0 11.5 0:08.56 java
24074 root 20 0 18.3g 924496 14500 S 0.0 11.5 0:08.56 java
24075 root 20 0 18.3g 924496 14500 S 0.0 11.5 0:08.62 java
24076 root 20 0 18.3g 924496 14500 S 0.0 11.5 0:08.57 java
24077 root 20 0 18.3g 924496 14500 S 0.0 11.5 0:08.60 java
24078 root 20 0 18.3g 924496 14500 S 0.0 11.5 0:08.60 java
24079 root 20 0 18.3g 924496 14500 S 0.0 11.5 0:08.57 java

2.使用jstack将进程的快照dump到本地

$ jstack -l 24062 > /tmp/jstack.log

3.查看进程24062下 子进程的cpu占用情况,查看哪些子进程占用cpu比较高 24214

$ top -H -p 24062
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
24214 root 20 0 18.3g 924508 14500 S 90.0 11.5 8:02.91 java
24062 root 20 0 18.3g 924508 14500 S 0.0 11.5 0:00.01 java
24063 root 20 0 18.3g 924508 14500 S 0.0 11.5 0:22.24 java
24064 root 20 0 18.3g 924508 14500 S 0.0 11.5 0:08.51 java
24065 root 20 0 18.3g 924508 14500 S 0.0 11.5 0:08.46 java
24066 root 20 0 18.3g 924508 14500 S 0.0 11.5 0:08.61 java
24067 root 20 0 18.3g 924508 14500 S 0.0 11.5 0:08.54 java
24068 root 20 0 18.3g 924508 14500 S 0.0 11.5 0:08.53 java
24069 root 20 0 18.3g 924508 14500 S 0.0 11.5 0:08.54 java
24070 root 20 0 18.3g 924508 14500 S 0.0 11.5 0:08.64 java
24071 root 20 0 18.3g 924508 14500 S 0.0 11.5 0:08.67 java
24072 root 20 0 18.3g 924508 14500 S 0.0 11.5 0:08.57 java
24073 root 20 0 18.3g 924508 14500 S 0.0 11.5 0:08.56 java
24074 root 20 0 18.3g 924508 14500 S 0.0 11.5 0:08.56 java
24075 root 20 0 18.3g 924508 14500 S 0.0 11.5 0:08.62 java
24076 root 20 0 18.3g 924508 14500 S 0.0 11.5 0:08.57 java
24077 root 20 0 18.3g 924508 14500 S 0.0 11.5 0:08.60 java

4.将24214转为16进制

$ echo 24214 | awk '{printf("%xn",$0)}'
5e96

5.在jstack.log中搜索查找5e96

可以定位到线程和相应的代码位置行数

比较可能出现的问题:

1.有个复杂对象没有使用单例模式生成,频繁生成导致cpu使用率很高
2.有内存泄露,频繁gc导致。如创建线程没有回收 参考博客

已有 17 条评论
  1. StevWews

    Buying Dog Thyroxine cialis 20mg price at walmart Finasteride Propecia How To Get A Bottle Of Viagra Propecia Without Prescription Buy

    StevWews December 3rd, 2019 at 11:24 am回复
  2. LesAstona

    Where Can I Get Metformin http://cialibuy.com - Buy Cialis Viagra Rezeptfrei Apotheke Buy Cialis Super Kamagra Deutschland

    LesAstona January 23rd, 2020 at 02:07 pm回复
  3. MatInfoge

    Pour Amoxil D' http://cialibuy.com - Cialis Amoxicillin Gluten Cialis Macrobid Tablets Medication Cash Delivery Online

    MatInfoge January 25th, 2020 at 10:40 am回复
  4. StevWews

    Zithromax Purchase Canada http://cialisjh.com - Cialis Levitra Maker cialis 5mg best price Viagra Kaufen Aber Wo

    StevWews February 2nd, 2020 at 06:56 pm回复
  5. LesAstona

    Buy Atomoxetine Online http://cialibuy.com/# - Buy Cialis Cialis Online No Prescription Buy Cialis Buy Ciprofloxacin Hydrochloride

    LesAstona February 5th, 2020 at 02:53 pm回复
  6. LesAstona

    Viagra Ohne Rezept Kaufen Legal http://buycialisuss.com - п»їcialis Achat Levitra En Fr Buy Cialis Enzyte Drug Interactions

    LesAstona February 26th, 2020 at 09:17 pm回复
  7. StevWews

    Costo Cialis http://buycialisuss.com - online pharmacy Vrai Viagra Pas Cher cialis 5 mg Acheter Cialis Effet

    StevWews March 2nd, 2020 at 06:04 am回复
  8. MatInfoge

    Viagra Efectos En El Hombre http://apcialisle.com/# - Buy Cialis Cialis 0 5 Buy Cialis Cialis Venta

    MatInfoge March 4th, 2020 at 07:00 pm回复
  9. Stepsok

    Amoxicilan Buy Cialis Buy Cialis 20mg Fda Approved Pharmacy cialis 5mg Viagra Pfizer Internet

    Stepsok March 9th, 2020 at 03:47 am回复
  10. Stepsok

    Levitra Wholesale No Prescription generic cialis Amoxicilina For Sale On Line Pharmacy Buy Cialis Amitriptyline

    Stepsok March 14th, 2020 at 10:14 am回复
  11. Janmit

    Real Doxycycline Drugs Shipped Ups Buy Cialis Buy Cialis Online cialis Clomid 2 Par Aliment

    Janmit March 16th, 2020 at 10:42 am回复
  12. Stepsok

    Uti And Amoxicillin canadian pharmacy cialis 20mg Zithromax Dose In Children Cialis Buy Cialis 40 Mg No Prescription

    Stepsok March 17th, 2020 at 04:45 am回复
  13. Janmit

    Amoxicillin Treats Cialis Valore Propecia buy cialis online overnight shipping Nebenwirkungen Cialis 5mg

    Janmit March 23rd, 2020 at 01:11 pm回复
  14. Stepsok

    Amoxicillin Canine Dose buy cialis online india No Precreption Avodart 0.5 Mg Cialis Clomid Vente

    Stepsok March 23rd, 2020 at 03:57 pm回复
  15. Janmit

    Cipro Prix De Vente Cialis Viagra Purchase Australia Cialis Commenti Su Dapoxetina

    Janmit April 20th, 2020 at 12:38 pm回复
  16. Janmit

    Buy Xenical Slimming Pills Cialis Canada No Prescription Propecia Finasteride buy cialis online reddit Viagra Online Canada Overnight

    Janmit April 27th, 2020 at 05:39 am回复
  17. unirtiern

    What Is Ic Cephalexin https://ascialis.com/ - buying cialis online safely Cialis Mail Order cialis online reviews Acheter Baclofen En Ligne

    unirtiern July 5th, 2020 at 02:59 am回复
发表新评论