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

java.lang.OutOfMemoryError:unable to create new native thread

热度:611   发布时间:2016-04-24 15:25:19.0
java.lang.OutOfMemoryError
由于并发用户较多,且程序比较复杂,在服务器运行一段时间之后就会出现
java.lang.OutOfMemoryError:unable   to   create   new   native   thread
的提示。
服务器是2G内存,我看了一下服务器内存的使用情况很好啊,只有几百M使用了,高手帮忙解决下啊

------解决方案--------------------
1, Check your program memory leaks.
2, Increase JVM heap memory may help a bit.
------解决方案--------------------
1.首先根据应用来看,如果它确实需要用到1G内存.你只给它500M,它一定出错.可以通过调整JVM参数来改变.
2.程序的问题.慢慢找吧..
------解决方案--------------------
这个我不懂,向大家学习
------解决方案--------------------
2G的内存应该够的,至于造成
java.lang.OutOfMemoryError:unable to create new native thread
我想应该是你没有把多余的进程destory掉的缘故。
以下是一些解决方法,仅供参考
Solution
There are a few things to do if you encounter this exception.


Use the lsof -p PID command (Unix?platforms) to see how many threads are active for this process.


Determine if there is a maximum number of threads per process defined by the operating system. If the limit is too low for the application, try raising the per-process thread limit.


Examine the application code to determine if there is code that is creating threads or connections (such as LDAP connections) and not destroying them. You could dump the Java?threads to see if there are an excessive number has been created.


If you find that too many connections are opened by the application, make sure that any thread that the application creates is destroyed. An enterprise application (.ear) or Web application (.war) runs under a long-running JVM? Just because the application is finished does not mean that the JVM process ends. It is imperative that an application free any resources that it allocates. Another solution would be for the application to use a thread pool to manage the threads needed.






------解决方案--------------------
运行时加入参数:-Xmx1024m
------解决方案--------------------
多数情况都是程序问题,如果用tomcat,最好还是用tomcat6,改进过了
------解决方案--------------------
可能有以下的原因
1.程序出现错误,找服务器的log看看
2.用了太复杂的查询,要优化查询语句
3.查出了海量的数据,加些限制条件控制数据
------解决方案--------------------
死循环了
------解决方案--------------------
我记得好像是把编译器中的一个预编译的属性去掉就ok了
  相关解决方案