I\'ve been reading and testing and banging my head on the wall for over a day because of this error.
I have some Java code in a class called Listener
t
You can be limit by max user processes
, to know your limit use :
ulimit -u
To change the limit :
In /etc/security/limits.conf
set :
user soft nproc [your_val]
user hard nproc [your_val]
You may have to add some other config if it's not enough see this link.
Note : The OP found this bug report in fedora and centos which explains the limitations of editing /etc/security/limits.conf
.
Your problem is probably related with JVM being unable to allocate stack memory for new threads. Ironically, this problem can be solved by decreasing heap space (-Xmx) and stack space (-Xss). Check here, for instance, for a good explanation: http://www.blogsoncloud.com/jsp/techSols/java-lang-OutOfMemoryError-unable-to-create-new-native-thread.jsp
Just for clarification:
You provide a ServerSocket
to the Thread
. Do you send Data to that Socket? Maybe you store to much data within the Thread-Context. Tak a look for a pattern, where you store Streamdata in an byte[]
.
It's not missing memory for your new threads, it's missing actual threads. The system is probably stopping you: there's a limit to the number of thread a user can create. You can query it that way:
cat /proc/sys/kernel/threads-max
Note that you might be impacted by other processes on the same machine, you they create many thread too. You might find this question useful: Maximum number of threads per process in Linux?