linux环境JVM内存死锁问题分析

最近在一次压力测试问题分析中,发现运行在tomcat的应用,不管上多少个vuser模拟请求压力,只会耗用200%的cpu,测出应用的tps很低,近10次每秒。经过分析,不是网卡的瓶颈,于是怀疑是内存锁的问题,于是就以下操作与分析。

步骤一:在linux环境上执行jstack -l 线程号 >线程号.log

步骤二:从.log发现如下问题0x0000000751968760 的内存变量一个锁住,另一个在获取锁。出现死锁问题。
"http-apr-8090-exec-3898" daemon prio=10 tid=0x00007fa47e67b800 nid=0x192ac waiting for monitor entry [0x00007fa2eb978000]
   java.lang.Thread.State: BLOCKED (on object monitor)
at org.apache.log4j.Category.callAppenders(Category.java:204)
- parking to wait for  <0x0000000751968760> (a org.apache.log4j.Logger)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.log(Category.java:856)
at com.xx.esi.log.logger.log4j.Log4jLogger.info(Log4jLogger.java:45)
at com.xx.esi.log.logger.support.FailsafeLogger.info(FailsafeLogger.java:119)
at com.xx.cb.web.servlet.HttpService.doPost(HttpService.java:116)



"http-apr-8090-exec-3315" daemon prio=10 tid=0x00007fa47c7f4800 nid=0x19064 runnable [0x00007fa2f608a000]
   java.lang.Thread.State: RUNNABLE
at java.util.Arrays.copyOf(Arrays.java:2367)
at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:130)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:114)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:415)
at java.lang.StringBuffer.append(StringBuffer.java:237)
- locked <0x000000071fe7ee58> (a java.lang.StringBuffer)
at org.apache.log4j.helpers.PatternParser$LiteralPatternConverter.format(PatternParser.java:419)
at org.apache.log4j.PatternLayout.format(PatternLayout.java:506)
at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:310)
at org.apache.log4j.DailyRollingFileAppender.subAppend(DailyRollingFileAppender.java:369)
at org.apache.log4j.WriterAppender.append(WriterAppender.java:162)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
- locked <0x0000000751d00418> (a org.apache.log4j.DailyRollingFileAppender)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
at org.apache.log4j.Category.callAppenders(Category.java:206)
- locked <0x0000000751968760> (a org.apache.log4j.Logger)
at com.xx.cb.web.servlet.HttpService.doPost(HttpService.java:116)
步骤三:解决以上代码缺陷。

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。