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佔用率高的解決辦法
- cpu佔用率100%怎麼解決 cpu佔用率高怎麼辦
- Linux inode佔用100%的解決辦法Linux
- mysql佔用CPU過高的解決辦法(新增索引)MySql索引
- gtk-gnash大量佔用cpu解決辦法
- oracle資料庫cpu佔用居高不下的解決辦法Oracle資料庫
- java專案cpu佔用高排查方法(chatgpt)JavaChatGPT
- CPU佔用100%原因及解決方法 轉載
- 伺服器CPU跑滿的解決辦法伺服器
- win10開個遊戲就佔用100的CPU怎麼辦 win10玩遊戲就佔用100的CPU解決方法Win10遊戲
- WindowsXP系統CPU使用率100%解決辦法Windows
- 解決伺服器 CPU 佔用 100% 導致 PHP-fpm 程式假死問題伺服器PHP
- tomcat埠被佔用解決辦法Tomcat
- Win10絕地求生CPU佔用100%怎麼回事 Win10絕地求生CPU佔用100%的解決教程Win10
- 經驗功享:對CPU資源佔用100%的解決方法
- win10系統windows defender佔用CPU100怎麼解決Win10Windows
- win10磁碟佔用100%怎麼辦 win10磁碟佔用達到100%解決方法Win10
- vmware-vmx.exe程式CPU佔用率100%解決方法
- height:100%失效解決辦法
- win10正式版cpu佔用高的解決方法_win10正式版cpu佔用高怎麼辦Win10
- win10系統執行dnf時cpu佔用100怎麼解決Win10
- CPU常見小故障原因與解決辦法
- 「專案已被 macOS 使用,不能開啟」解決辦法Mac
- myeclipse專案報錯終極解決辦法Eclipse
- 檔案無法粉碎解決辦法
- win10系統玩流放之路cpu佔用100%如何解決Win10
- win10 2004系統cpu佔用高怎麼辦_win10 2004系統佔用cpu過高解決教程Win10
- java程式佔用cpu異常升高Java
- HP ILO被其他人開啟並佔用的解決辦法
- 程式猿是如何解決SQLServer佔CPU100%SQLServer
- 我是如何解決SQL Server CPU佔100%的SQLServer
- “專案檔案已被重新命名或已不在解決方案中”的解決辦法
- windows8.1磁碟佔用100%怎麼解決Windows
- 【閱讀筆記】jvm效能工具-jstat解決100%CPU佔用率分析筆記JVMJS
- 磁碟使用率100怎麼辦_win10磁碟佔用100%的5個解決方法Win10
- win10system佔用磁碟高怎麼辦_win10system佔用cpu高如何解決Win10
- java應用CPU佔用率過高排查Java
- Java讀取檔案中含有中文的解決辦法 (轉)Java