Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

POSIX_SPAWN with Java?

Tags:

java

posix

spawn

ProcessBuilder.start and Runtime.exec seem to use fork() on *NIX system, which seems to allocate the child process the same amount of memory as the parent process (see e.g. this question ). This can be painful if you want to launch a process which needs almost no memory from a process that uses lots of memory.

Is there any way to launch processes using POSIX_SPAWN -- which doesn't do this memory allocation? The only way I know of is using Tanuki, but turns out to be not ideal for me.

like image 928
Jacob Avatar asked May 07 '26 03:05

Jacob


1 Answers

Use the NuProcess library. It uses VFORK on Linux which does not copy the process space first, thereby eliminating the frequent OOM errors when forking processes from a java process with a large heap.

like image 96
brettw Avatar answered May 08 '26 15:05

brettw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!