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)
atorg.apache.log4j.Category.callAppenders(Category.java:204)
-parking to wait for <0x0000000751968760>(aorg.apache.log4j.Logger)
atorg.apache.log4j.Category.forcedLog(Category.java:391)
atorg.apache.log4j.Category.log(Category.java:856)
atcom.xx.esi.log.logger.log4j.Log4jLogger.info(Log4jLogger.java:45)
atcom.xx.esi.log.logger.support.FailsafeLogger.info(FailsafeLogger.java:119)
atcom.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)
atcom.xx.cb.web.servlet.HttpService.doPost(HttpService.java:116)
步骤三:解决以上代码缺陷。

相关推荐