5

In my application runs in amazon aws instance. In these i am getting the java.lang.OutofMemory error. My instance is running in ubuntu machine. Following is error I am getting. I have google about this but I am not find any solution about this error.

    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)

I want to know when these error is arise and how we will prevent this.

Thanks inadvance.

MadTech
  • 1,458
  • 3
  • 13
  • 32

1 Answers1

4

I had the same issue when running a lot of concurrent processes testing my application with JMeter. I am using Fedora and by default the process amount available is 1024.

You can check your maximum amount of processes by entering ulimit -u in the command line, and to change the amount of maximum processes permanently, you just have to edit the file under /etc/security/limits.conf and add the following lines in the end of the file:

username soft nproc xx

username hard nproc xx

e.g. set 10000 max processes to user 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

ibai
  • 1,143
  • 1
  • 17
  • 28