java.io.IOException: Cannot run program "/usr/local/bin/sudo": error=12, Not enough space
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:466)
...
Caused by: java.io.IOException: error=12, Not enough space
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:53)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)

when I tried to call an external script by Runtime.exec. I checked the physical memory and swap, both of them were more than 2GB around the time when the exception was thrown. The same exception was thrown by other external process forking thread...

Would anyone please shed me some lights on this issue? I didn't see any OutOfMemoryError either from my application.

I'm forking a script in one JVM to monitor mySQL status, the script is a little big complex and I don't know how big it's as it's not owned by myself. But another JVM is forking "pgrep svmdmn", while svmdmn is the name of a process. The 2nd fork was failed with the not enough space either...

why is 2GBytes swap space not enough for a simple "pgrep svmdmn"? ... does it mean that the simple fork will be failed as there would be a "big" fork to be present at the same moment?

You're answering the wrong question. fork() duplicates whatever is running that is calling the fork(). The forked child process is then replaced by the target process, which may be smaller, but that's not the question I'm asking..

I made a mistake when caculating the free swap...I misunderstood that the result of "sar -r" showed the free "pages" of swap space just like the free memory...however it's free "blocks"...that's to say, we have only 1-2G average and 400M as the lowest free swap space which is not enough absolutely.

I will double check with the customer to see if customer allocated too small swap space as this issue was never met before.