大约 3 个月前,我们迁移到 JBoss 5.1.0.GA,在测试几天后,我们在应用程序的日志中发现了几个内存不足错误 (OOME)。
然后我发现了一个问题,该问题将原因描述为 JVM 版本 7 之前的错误。我们更新到版本 7u25,我们没有看到更多的 OOME,但现在我看到异常巨大的线程数:大约 2k 线程,其中 1.9 k 是守护线程。
在查看我们的监控工具后发现,它们都是由JBoss系统线程池生成的线程(它们都被命名为JBoss System Threads(1)-XXXX)。这是堆栈跟踪详细信息:
"JBoss System Threads(1)-1649" Id=130217 in WAITING on lock=java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@a4d1d3
at sun.misc.Unsafe.park(Native Method)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
我还检查了收集泄漏的工具,发现了我认为有些相关的下一个数据:
我检查了 JBoss JIRA,但没有找到相关的东西。
有人可以指出发生了什么吗?
更新:
这是 jboss-service.xml 中的线程池配置
<!-- A Thread pool service -->
<mbean code="org.jboss.util.threadpool.BasicThreadPool"
name="jboss.system:service=ThreadPool">
<attribute name="Name">JBoss System Threads</attribute>
<attribute name="ThreadGroupName">System Threads</attribute>
<!-- How long a thread will live without any tasks in MS -->
<attribute name="KeepAliveTime">60000</attribute>
<!-- The max number of threads in the pool -->
<attribute name="MaximumPoolSize">3200</attribute>
<!-- The max number of tasks before the queue is full -->
<attribute name="MaximumQueueSize">3200</attribute>
<!-- The behavior of the pool when a task is added and the queue is full.
abort - a RuntimeException is thrown
run - the calling thread executes the task
wait - the calling thread blocks until the queue has room
discard - the task is silently discarded without being run
discardOldest - check to see if a task is about to complete and enque
the new task if possible, else run the task in the calling thread
-->
<attribute name="BlockingMode">run</attribute>
</mbean>