Java – Resource temporarily unavailable [fork] & insufficient memory for the Java Runtime Environment to continue

centos6javajvm

I have been experiencing this errors in my linux servers.

Resource temporarily unavailable [fork] &  
insufficient memory for the Java Runtime Environment to continue

I have increased the nproc limit in my server to 2047. And I hope that resourse unavailable message will not come again

But while entering the java command itself, it is throwing the error "Insufficent memory". I tried to set the java heap memory but that also not allowing. I am not sure how to proceed further. Please help!!

OS is Centos 6.8
Java Version is Jdk 1.6
Virtualization is LXC
multiple Virtual machines are running in host server.
Free memory is 15GB across all virtual machines.

Since it is LXC virtualization, it is having the shared memory across all virtual machines.

Best Answer

Since I am using the LXC containers, all the processes of the VM's are are originated from the Host server. So number of process on the host server was very large if we exclude the root user.

Initially thought that it may be because of Java Heap space issue and i tried to increase the heap space to a larger value. But the issue was repeating.

I resolved the issue by increasing the number of process for user in Host server

/etc/security/limits.d/90-nproc.conf

to a large value of 16000.

And also I increased the number of process in each VM's to a higher value of 4096.

Now both the issues of "Resource temporarily unavailable [fork] & insufficient memory for the Java Runtime Environment to continue" are resolved. And everything is working fine now.