Java中的OutOfMemoryError:无法创建新的本地线程(Play Framework)

5

我的应用在亚马逊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)

我想知道这些错误是何时出现的,以及我们该如何预防。谢谢。

停止和启动Web服务器... - Narayan Subedi
地址空间不足? - fge
不,那不是出现地址空间问题。 - MadTech
你怎么能这么确定呢? - fge
1个回答

4
我在使用JMeter测试应用程序时,同时运行大量并发进程时遇到了同样的问题。我正在使用Fedora,而默认情况下可用的进程数量为1024。
您可以通过在命令行中输入来检查您的最大进程数,并且要永久更改最大进程数的数量,您只需编辑/etc/security/limits.conf文件,在文件末尾添加以下行: username soft nproc xx username hard nproc xx
例如,将最大进程数设置为10000个用户ibai,请执行以下操作: ibai soft nproc 10000 ibai hard nproc 10000 https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Tuning_and_Optimizing_Red_Hat_Enterprise_Linux_for_Oracle_9i_and_10g_Databases/sect-Oracle_9i_and_10g_Tuning_Guide-Setting_Shell_Limits_for_the_Oracle_User-Limiting_Maximum_Number_of_Processes_Available_for_the_Oracle_User.html

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接