Make Limits Java Heap Size on 32-bit Linux
Here’s a fun one. The following command:
java -Xmx2g Test
works fine when run from the command-line, but not when run from within a make recipe. It errors out with the following message:
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
After a substantial amount of web searching, I still don’t have a good answer as to why this is, but it seems only to be an issue on 32-bit versions of Linux, as mentioned here: https://community.oracle.com/thread/1543487. My guess is that
make somehow limits the amount of memory it and its sub-processes can allocate, but I haven’t been able to confirm this. If I get any answers, I’ll post an update.