在我的应用程序中运行amazon aws实例。在这些我得到java.lang.OutofMemory错误。我的实例在ubuntu机器上运行。以下是我得到的错误。我有关于此的谷歌,但我找不到任何有关此错误的解决方案。
java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:640)
at java.util.concurrent.ThreadPoolExecutor.addIfUnderMaximumPoolSize(ThreadPoolExecutor.java:727)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:657)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:176)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:156)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:325)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
我想知道这些错误何时出现以及我们将如何防止这种情况发生。
非常感谢。
答案 0 :(得分:3)
你确定你对谷歌有所了解吗? http://javaeesupportpatterns.blogspot.de/2012/09/outofmemoryerror-unable-to-create-new.html
答案 1 :(得分:3)
当运行大量并发进程使用JMeter测试我的应用程序时,我遇到了同样的问题。我正在使用Fedora,默认情况下可用的处理量为1024.
您可以通过在命令行中输入 ulimit -u 来检查最大进程数,并永久更改最大进程数,只需在 /下编辑该文件即可etc / security / limits.conf 并在文件末尾添加以下行:
用户名soft nproc xx
username hard nproc xx
e.g。将10000个最大进程设置为用户ibai
ibai soft nproc 10000
ibai hard nproc 10000