【问题标题】:jstack 100% CPUjstack 100% CPU
【发布时间】:2012-10-05 05:04:07
【问题描述】:

所以我一直想弄清楚为什么我们的应用程序偶尔会消耗 100% 的 CPU。我已经阅读了几篇非常有用的 stackovertflow 帖子,但我认为为了安全起见,我想获得一些建议......指导......帮助......无论如何。实际上,这也归结为我缺乏查看堆栈跟踪的经验。如果有人能在这里指出可能的罪魁祸首并向我展示这样的指针,我将非常感激,以便我能更好地理解这一点。

值得注意的线程(在我看来)是等待监视器的线程:

我一直得到其中四个线程 jndi-0 - jndi-4 “jndi-0”prio=6 tid=0x000000001113e000 nid=0x187c 等待监视器条目 [0x0000000012a9f000] java.lang.Thread.State: BLOCKED (在对象监视器上) 在 java.net.PlainSocketImpl.accept(PlainSocketImpl.java:388) - 等待锁定(java.net.SocksSocketImpl) 在 java.net.ServerSocket.implAccept(ServerSocket.java:453) 在 java.net.ServerSocket.accept(ServerSocket.java:421) 在 jrun.servlet.network.NetworkService.accept(NetworkService.java:356) 在 jrun.naming.NamingNetworkService.accept(NamingNetworkService.java:115) 在 jrun.naming.NamingNetworkService.createRunnable(NamingNetworkService.java:141) 在 jrunx.scheduler.ThreadPool$DownstreamMetrics.createRunnable(ThreadPool.java:287) 在 jrunx.scheduler.ThreadPool$ThreadThrottle.createRunnable(ThreadPool.java:349) 在 jrunx.scheduler.ThreadPool$UpstreamMetrics.createRunnable(ThreadPool.java:241) 在 jrunx.scheduler.WorkerThread.run(WorkerThread.java:62) 锁定的可拥有同步器: - 没有任何 “jrpp-298”prio=6 tid=0x0000000014730800 nid=0xdd4 等待监视器条目 [0x000000001cc4b000] java.lang.Thread.State: BLOCKED (在对象监视器上) 在coldfusion.runtime.LocalScope.put(LocalScope.java:247) - 等待锁定(coldfusion.runtime.VariableScope) 在coldfusion.runtime.NeoPageContext.SymTab_setValidatedSimpleName(NeoPageContext.java:1339) 在coldfusion.runtime.NeoPageContext.SymTab_setValidatedDottedName(NeoPageContext.java:1297) 在coldfusion.runtime.NeoPageContext.setValidatedAttribute(NeoPageContext.java:524) 在coldfusion.runtime.NeoPageContext.setAttribute(NeoPageContext.java:392) 在coldfusion.runtime.CfJspPage._set(CfJspPage.java:369) 在 cfmathFunctions2ecfm1090027769$funcREDUCEBARBASE.runFunction(C:\SIWEB\cfw\controllers\ContentLogic\mathFunctions.cfm:711) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:418) 在coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:324) 在coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:59) 在coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:277) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:192) 在coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2471) 在 Statement26069.evaluate(:1) 在coldfusion.compiler.ExprClassLoader.evaluate(ExprClassLoader.java:143) 在coldfusion.runtime.CFPage.Evaluate(CFPage.java:1726) 在 cfContentLogic2ecfc1938419849$funcEVALUATEFUNCTIONSTRING.runFunction(C:\SIWEB\cfw\controllers\ContentLogic.cfc:479) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:418) 在coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:324) 在coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:59) 在coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:277) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:463) 在coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2436) 在 cfContentLogic2ecfc1938419849$funcFINDANDEVALUATE.runFunction(C:\SIWEB\cfw\controllers\ContentLogic.cfc:528) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:418) 在coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47) 在coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:360) 在coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:324) 在coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:59) 在coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:277) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:192) 在coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2471) 在 cfContentLogic2ecfc1938419849$funcPREPAREDANSWERSBYQUESTIONIDQGID.runFunction(C:\SIWEB\cfw\controllers\ContentLogic.cfc:340) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:418) 在coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:360) 在coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:324) 在coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:59) 在coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:277) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:463) 在coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2436) 在 cfContentLogic2ecfc1938419849$funcPROCESSDYNAMICITEMBYQUESTIONIDQGID.runFunction(C:\SIWEB\cfw\controllers\ContentLogic.cfc:69) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:418) 在coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:360) 在coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:324) 在coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:59) 在coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:277) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:463) 在coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:453) 在coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:320) 在coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2222) 在 cfitemPackaging2ecfm1230617345$funcPREPAREDITEMBYQUESTIONIDQGID.runFunction(C:\SIWEB\cfw\controllers\ProtectedBusinessLogic\itemPackaging.cfm:693) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:418) 在coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:324) 在coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:59) 在coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:277) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:463) 在coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2436) 在 cfitemPackaging2ecfm1230617345$funcPREPAREDITEMSANDPASSAGESSTRUCTBYQGID.runFunction(C:\SIWEB\cfw\controllers\ProtectedBusinessLogic\itemPackaging.cfm:408) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:418) 在coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:360) 在coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:324) 在coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:59) 在coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:277) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:463) 在coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2436) 在 cfitemPackaging2ecfm1230617345$funcPREPAREDITEMSANDPASSAGESSTRUCTBYQGIDS.runFunction(C:\SIWEB\cfw\controllers\ProtectedBusinessLogic\itemPackaging.cfm:73) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:418) 在coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:360) 在coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:324) 在coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:59) 在coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:277) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:463) 在coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:453) 在coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:320) 在coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2222) 在 cfpracticesession2ecfm1218050444$funcPRACTICESESSION.runFunction(C:\SIWEB\cfw\controllers\Test\practicesession.cfm:272) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:418) 在coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:324) 在coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:59) 在coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:277) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:463) 在coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2436) 在coldfusion.tagext.lang.InvokeTag.doEndTag(InvokeTag.java:432) 在coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2662) 在 cfcfml2ecfm667848367$func$INVOKE.runFunction(C:\SIWEB\cfw\wheels\global\cfml.cfm:177) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:418) 在coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47) 在coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:360) 在coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:324) 在coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:59) 在coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:277) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:463) 在coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2436) 在 cfprocessing2ecfm76711320$func$CALLACTION.runFunction(C:\SIWEB\cfw\wheels\controller\processing.cfm:85) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:418) 在coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47) 在coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:360) 在coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:324) 在coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:59) 在coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:277) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:463) 在coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2436) 在 cfprocessing2ecfm76711320$func$PROCESSACTION.runFunction(C:\SIWEB\cfw\wheels\controller\processing.cfm:60) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:418) 在coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47) 在coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:360) 在coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:324) 在coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:59) 在coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:277) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:192) 在coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:448) 在coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:308) 在coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2272) 在 cfrequest2ecfm104933708$func$REQUEST.runFunction(C:\SIWEB\cfw\wheels\dispatch\request.cfm:166) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:418) 在coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47) 在coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:360) 在coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:324) 在coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:59) 在coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:277) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:192) 在coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:448) 在coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:308) 在coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2272) 在 cfindex2ecfm812783003.runPage(C:\SIWEB\cfw\wheels\index.cfm:1) 在coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:196) 在coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:370) 在coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2661) 在 cfrewrite2ecfm453288076.runPage(C:\SIWEB\cfw\rewrite.cfm:1) 在coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:196) 在coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:370) 在coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2661) 在 cfonrequest2ecfm951311187$funcONREQUEST.runFunction(C:\SIWEB\cfw\wheels\events\onrequest.cfm:1) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:418) 在coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:360) 在coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:324) 在coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:59) 在coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:277) 在coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:192) 在coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:448) 在coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:308) 在coldfusion.runtime.AppEventInvoker.invoke(AppEventInvoker.java:74) 在coldfusion.runtime.AppEventInvoker.onRequest(AppEventInvoker.java:243) 在coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:269) 在coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48) 在coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) 在coldfusion.filter.PathFilter.invoke(PathFilter.java:86) 在coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70) 在coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) 在coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) 在coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46) 在coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) 在coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) 在coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:126) 在coldfusion.CfmServlet.service(CfmServlet.java:175) 在coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) 在 jrun.servlet.FilterChain.doFilter(FilterChain.java:86) 在 com.intergral.fusionreactor.filter.FusionReactorFilter.k(FusionReactorFilter.java:636) 在 com.intergral.fusionreactor.filter.FusionReactorFilter.d(FusionReactorFilter.java:266) 在 com.intergral.fusionreactor.filter.FusionReactorFilter.doFilter(FusionReactorFilter.java:171) 在 jrun.servlet.FilterChain.doFilter(FilterChain.java:94) 在coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42) 在coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) 在 jrun.servlet.FilterChain.doFilter(FilterChain.java:94) 在 jrun.servlet.FilterChain.service(FilterChain.java:101) 在 jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106) 在 jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) 在 jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286) 在 jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543) 在 jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203) 在 jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320) 在 jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428) 在 jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266) 在 jrunx.scheduler.WorkerThread.run(WorkerThread.java:66) 锁定的可拥有同步器: - 没有任何 跟踪时间:10:50:51.504 2012 年 9 月 18 日线程 ID:0x19 (25) 线程名称:jndi-3 优先级:5 哈希码:290417686 状态:RUNNABLE"jndi-3" prio=5 runnablejava.net.PlainSocketImpl.socketAccept(PlainSocketImpl.java :???)[Native Method]java.net.PlainSocketImpl.accept(PlainSocketImpl.java:390)java.net.ServerSocket.implAccept(ServerSocket.java:453)java.net.ServerSocket.accept(ServerSocket.java:421 )jrun.servlet.network.NetworkService.accept(NetworkService.java:356)jrun.naming.NamingNetworkService.accept(NamingNetworkService.java:115)jrun.naming.NamingNetworkService.createRunnable(NamingNetworkService.java:141)jrunx.scheduler.ThreadPool $DownstreamMetrics.createRunnable(ThreadPool.java:287)jrunx.scheduler.ThreadPool$ThreadThrottle.createRunnable(ThreadPool.java:349)jrunx.scheduler.ThreadPool$UpstreamMetrics.createRunnable(ThreadPool.java:241)jrunx.scheduler.WorkerThread.run (WorkerThread.java:62)

【问题讨论】:

  • 这些线程被阻塞,这意味着它们应该使用任何 CPU。你能找到 RUNNABLE 线程吗?
  • 可能有一个线程被锁定并导致其他线程阻塞。并且因为它不解锁显示器永远无法继续。我猜。
  • 您发布的堆栈跟踪是Threads,它们被阻止,因此目前不消耗任何CPU。发现哪个Thread(或Threads)正在使用你的所有CPU的最简单方法是将分析器附加到你的应用程序:此类分析器的示例是JProfiler,甚至是免费提供的JVisualVM。您还可以使用一些命令行实用程序来发现 Thread 占用您的 CPU 的堆栈跟踪。以this blogpost 为例
  • > 值得注意的线程(在我看来)是等待的线程 > 监视器:实际上这些并不值得注意,因为它们处于WAITING 状态并且不消耗 CPU。您应该检查RUNNING 线程。要么某个线程执行了 CPU 密集型的操作(这很糟糕吗?你能改进它吗?应该知道)或者另一个想到的是活锁。您的线程内容适用于 CPU,但没有完成任何实际进展。如果你的进程完成了它的工作,但只是消耗了太多的 CPU,你可以排除活锁。
  • 所以我很确定这是导致阻塞的线程(我发布的最后一个线程)

标签: java multithreading cpu jrun jstack


【解决方案1】:

我会推荐尝试 JVisualVM - 它非常适合通过线程进行排序。另一个不错的选择是使用 Eclipse,它也可以让您在调试模式下单步执行各个线程。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-12-29
    • 2015-09-27
    • 1970-01-01
    • 2012-01-26
    • 2017-05-23
    • 2016-11-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多