当前位置: 代码迷 >> J2EE >> java.lang.OutOfMemoryError: unable to create new native thread,该怎么解决
  详细解决方案

java.lang.OutOfMemoryError: unable to create new native thread,该怎么解决

热度:581   发布时间:2016-04-22 01:16:23.0
java.lang.OutOfMemoryError: unable to create new native thread
catalina.2012-06-06.log错误日志:
2012-6-6 9:51:21 org.apache.tomcat.util.http.Parameters processParameters
警告: Parameters: Invalid chunk ignored.
2012-6-6 9:52:23 org.apache.tomcat.util.net.JIoEndpoint processSocket
严重: Error allocating socket processor
java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:597)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.start(JIoEndpoint.java:478)
at org.apache.tomcat.util.net.JIoEndpoint.newWorkerThread(JIoEndpoint.java:697)
at org.apache.tomcat.util.net.JIoEndpoint.createWorkerThread(JIoEndpoint.java:676)
at org.apache.tomcat.util.net.JIoEndpoint.getWorkerThread(JIoEndpoint.java:708)
at org.apache.tomcat.util.net.JIoEndpoint.processSocket(JIoEndpoint.java:743)
at org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run(JIoEndpoint.java:320)
at java.lang.Thread.run(Thread.java:619)



JVM启动参数设置:
JAVA_OPTS=-server -Xms1024m -Xmx1024m -XX:PermSize=128m -XX:MaxNewSize=256m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError

tomcat使用的内存只有400M左右,请问这是什么问题呢?

------解决方案--------------------
你创建的线程数太多,导致无法再创建新的线程了。
------解决方案--------------------
这个问题,记得是有说法的:

你给JVM内存越多,那么你能创建的线程越少,越容易发生:
java.lang.OutOfMemoryError: unable to create new native thread。 

参见:
http://sesame.iteye.com/blog/622670


话说,你到底创建了多少线程啊。。。。。。
  相关解决方案