Suppose I'm invoking a command line program through java using following code segment
p = Runtime.getRuntime().exec(command);
p.waitFor();
In this case, how much memory will be allocated to command
the program invoked by exec
? Does it have anything to do with memory allocated for jvm
?
If so, How can I overcome this limitation?
UPDATE
According to an answer given for this question, How to solve "java.io.IOException: error=12, Cannot allocate memory" calling Runtime#exec()?
Runtime.getRuntime().exec allocates the process with the same amount of memory as the main. If you had you heap set to 1GB and try to exec then it will allocate another 1GB for that process to run.
So is there any way by which, I can have more memory for the process that I'm invoking using java?
What if I run command through command prompt like this?
rt.exec("cmd.exe /c command");
In this case, who will decide memory limit? Command Prompt or Java?