我提示我的服务器应用程序在高负载时崩溃。
它是一个在 Tomcat 5
中运行的网络应用程序。
我看到了线程转储,我看到有一个 OutOfMemory 错误
1TISIGINFO Dump Event "systhrow" (00040000) Detail
"java/lang/OutOfMemoryError" "Failed to create thread: retVal -1073741830, errno 12" >received 1TIDATETIME Date: 2012/07/17 at 20:03:17 1TIFILENAME >Javacore filename:C:\ServerApplication\Tomcat5\bin\javacore.34545719.4646464.4172.0003.txt
堆信息如下:
Maximum Java heap size : 1500m
Initial Java heap size : 256m
这是初始和最大堆大小的配置(32 位 java)
我还看到有可用的空闲堆空间
1STHEAPFREE Bytes of Heap Space Free: 2D19F3C0
1STHEAPALLOC Bytes of Heap Space Allocated: 5DC00000
这是大约 750MB 的可用空间,对吧?
从线程方法分析我看到线程的数量是695
其中49%
是java/lang/Object.wait(Native Method )
和 39%
在 sun/misc/Unsafe.park(Native Method)
我还看到这个 NO JAVA STACK 1%
不知道那是什么意思。
也有 0 个线程死锁并且 2%
是可运行的。
我不确定如何解释此信息或如何从这里继续检测根本原因。
有什么帮助吗?
最佳答案
根据 this post :
There are two possible causes of the java.lang.OutOfMemoryError: Failed to create a thread message:
- There are too many threads running and the system has run out of internal resources to create new threads.
- The system has run out of native memory to use for the new thread. Threads require a native memory for internal JVM structures, a Java™ stack, and a native stack.
所以这个错误很可能与内存完全无关,只是创建了太多线程......
编辑:
由于您有 695 个线程,因此您需要 695 倍于堆栈大小的内存。考虑 this post关于线程限制,我怀疑您正试图为可用的虚拟内存空间创建太多线程。
关于java - 如何检测 OutofMemoryError 的原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11682726/