Java專案伺服器cpu佔用100%解決辦法
專案上線後執行一段時間,突然發現cpu 8個邏輯核心都佔用100%,心情很緊張,然後就在網上找了一些解決方法,具體如下:
1.查詢哪些程式在耗cpu
進入伺服器,top 命令看一下,發現程式6633佔用了800%
[root@server ~]# top
2.把程式的棧dump到檔案裡,以便後面的分析
[root@server ~]# jstack 23812 >> java.txt
3.看看這個程式裡面哪些執行緒在佔用cpu
[root@server ~]# top -p 23812 -H
一大片佔用cpu很高的執行緒,選一個最高的吧,PID=15362
4.接著要看剛才dump出來的java.txt日誌了,裡面會有23812這個程式下面每個執行緒的棧資訊,但是是十六進位制顯示的,所以先把5159轉換成16進位制
[root@server ~]# printf %0x 15362
[root@server ~]# 3c02
5.在cpu日誌裡找PID=3c02的執行緒
[root@server ~]# vi java.txt
6.分析原因
[root@localhost ~]# grep “3c02” java.txt
“JS executor for com.gargoylesoftware.htmlunit.WebClient@4e96f35e” #76858 daemon prio=5 os_prio=0 tid=0x00007f390000b800 nid=0x3c02 runnable [0x00007f3ae13db000]
“JS executor for com.gargoylesoftware.htmlunit.WebClient@4e96f35e” #76858 daemon prio=5 os_prio=0 tid=0x00007f390000b800 nid=0x3c02 runnable [0x00007f3ae13db000]
“JS executor for com.gargoylesoftware.htmlunit.WebClient@4e96f35e” #76858 daemon prio=5 os_prio=0 tid=0x00007f390000b800 nid=0x3c02 runnab
java.lang.Thread.State: RUNNABLE
at java.util.ArrayList.<init>(ArrayList.java:177)
at com.gargoylesoftware.htmlunit.html.HtmlPage.safeGetAttributeListeners(HtmlPage.java:2222)
– locked <0x00000005cd622798> (a java.lang.String)
at com.gargoylesoftware.htmlunit.html.HtmlPage.fireHtmlAttributeReplaced(HtmlPage.java:2198)
at com.gargoylesoftware.htmlunit.html.HtmlElement.setAttributeNS(HtmlElement.java:213)
at com.gargoylesoftware.htmlunit.html.DomElement.setAttribute(DomElement.java:296)
at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration.writeToElement(CSSStyleDeclaration.java:652)
at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration.replaceStyleAttribute(CSSStyleDeclaration.java:576)
at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration.setStyleAttribute(CSSStyleDeclaration.java:550)
at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration.setZIndex(CSSStyleDeclaration.java:3956)
at sun.reflect.GeneratedMethodAccessor135.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at net.sourceforge.htmlunit.corejs.javascript.MemberBox.invoke(MemberBox.java:120)
at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject$GetterSlot.setValue(ScriptableObject.java:295)
at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject$RelinkedSlot.setValue(ScriptableObject.java:368)
at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject.putImpl(ScriptableObject.java:2796)
at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject.put(ScriptableObject.java:521)
at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration.put(CSSStyleDeclaration.java:2407)
at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject.putProperty(ScriptableObject.java:2479)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.setObjectProp(ScriptRuntime.java:1574)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.setObjectProp(ScriptRuntime.java:1569)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1253)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:798)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:411)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:309)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3057)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:115)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$3.doRun(JavaScriptEngine.java:566)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:674)
– locked <0x00000005cd2f5a08> (a com.gargoylesoftware.htmlunit.html.HtmlPage)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:620)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:575)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:550)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:971)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptStringJob.runJavaScript(JavaScriptStringJob.java:50)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptExecutionJob.run(JavaScriptExecutionJob.java:102)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:328)
at com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:162)
at java.lang.Thread.run(Thread.java:745)
找到問題所在讓java開發排查
本文轉自 wjw555 51CTO部落格,原文連結:http://blog.51cto.com/wujianwei/1964359
相關文章
- cpu佔用率100%怎麼解決 cpu佔用率高怎麼辦
- mysql佔用CPU過高的解決辦法(新增索引)MySql索引
- java專案cpu佔用高排查方法(chatgpt)JavaChatGPT
- win10開個遊戲就佔用100的CPU怎麼辦 win10玩遊戲就佔用100的CPU解決方法Win10遊戲
- 伺服器CPU跑滿的解決辦法伺服器
- 解決伺服器 CPU 佔用 100% 導致 PHP-fpm 程式假死問題伺服器PHP
- tomcat埠被佔用解決辦法Tomcat
- Win10絕地求生CPU佔用100%怎麼回事 Win10絕地求生CPU佔用100%的解決教程Win10
- height:100%失效解決辦法
- win10磁碟佔用100%怎麼辦 win10磁碟佔用達到100%解決方法Win10
- win10系統windows defender佔用CPU100怎麼解決Win10Windows
- win10系統執行dnf時cpu佔用100怎麼解決Win10
- win10正式版cpu佔用高的解決方法_win10正式版cpu佔用高怎麼辦Win10
- win10 2004系統cpu佔用高怎麼辦_win10 2004系統佔用cpu過高解決教程Win10
- win10系統玩流放之路cpu佔用100%如何解決Win10
- 「專案已被 macOS 使用,不能開啟」解決辦法Mac
- 檔案無法粉碎解決辦法
- 磁碟使用率100怎麼辦_win10磁碟佔用100%的5個解決方法Win10
- win10磁碟佔用率100怎麼辦_win10磁碟佔用率100%的解決方法Win10
- CPU持續100%分析並解決
- java程式佔用cpu異常升高Java
- VS2015 解決方案 或者專案 卡 正在載入 的解決辦法
- Win10系統中斷程式佔用cpu100%怎麼辦 win10終端程式佔用100%電腦很卡如何處理Win10
- idea無法直接建立web專案的解決辦法(附整合Tomcat方法)IdeaWebTomcat
- gpu佔用率100%正常嗎 電腦gpu佔用高怎麼解決GPU
- win10system佔用磁碟高怎麼辦_win10system佔用cpu高如何解決Win10
- java應用CPU佔用率過高排查Java
- 電腦檔案被佔用無法刪除?Win10系統檔案被佔用無法刪除的解決方法Win10
- win10系統keyshot佔用率高cpu怎麼辦_win10 keyshot佔用率100%cpu處理方法Win10
- 遠端連線關閉,專案就停止的解決辦法
- win10磁碟100%各種卡死原因 磁碟佔用100%怎麼解決Win10
- 伺服器iis出現假死解決辦法伺服器
- 伺服器常見故障及解決辦法伺服器
- win10資料夾被佔用無法刪除怎麼辦_win10檔案被佔用刪不了的解決方法Win10
- win10系統explorer佔用cpu很高的解決方法Win10
- jvm:jmap無法dump檔案的解決辦法JVM
- 為什麼win10磁碟老是佔用100% win10磁碟佔用總是100%的解決步驟Win10
- 筆記本磁碟佔用率100怎麼辦_筆記本磁碟佔用一直是100%如何解決筆記
- 用CMD執行時Java,出現亂碼的解決辦法Java