I am starting too many processes in Java using:
Runtime.getRuntime().exec("java -ja myJar.jar")
When it reaches around 350 processes, I get an IO exception:
Cannot run program "java": java.io.IOException: error=24, Too many open files
Exception in creating process
at java.lang.ProcessBuilder.start(ProcessBuilder.java:475)
at java.lang.Runtime.exec(Runtime.java:610)
at java.lang.Runtime.exec(Runtime.java:448)
at java.lang.Runtime.exec(Runtime.java:345)
In each process I am using one database connection.
I am running ubuntu 32 bit OS. But when I run:
ulimit -u
I can see that process limit is unlimited. What could be the problem?
Running 350 JVM instances is not the normal way. Can you redesign and run 350 “main threads” within the same JVM. That is how servlet container works. All web applications are running in the same JVM.
PD. ulimit man pages says to see max. open files is ulimit -n.