POSIX_SPAWN with Java?

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

Is there a way to start processes using POSIX_SPAWN - which does not allocate this memory? The only way I know is to use Tanuki , but for me it is not ideal.

+3
source share
2 answers

Here's an open source project that implements posix_spawn

https://github.com/axiak/java_posix_spawn

+1
source

Use the NuProcess library . It uses VFORK for Linux, which at first does not copy the process space, thereby eliminating frequently occurring OOM errors when processing processes using a large heap java process.

+1
source

Source: https://habr.com/ru/post/1751689/


All Articles