I am setting ANT_OPTS in the environment to "-Xms256m -Xmx1024m". After setting this, I am not able to run ant files from command prompt. It throws me an error of:
"Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine."
Although I have enough physical memory available (more than 2048m available) to allot 1024m for ANT_OPTS, but still it throws the above error. Can there be any other reason why I cannot set Xmx to 1024m ?
Anyway, here is how to fix it:
Go to Start->Control Panel->System->Advanced(tab)->Environment Variables->System Variables->New:
or
set _JAVA_OPTS="-Xmx512M"
or
Change the ant call as shown as below.
<exec>
<arg value="-J-Xmx512m" />
</exec>
then build the files again using the ant. It worked for me.
You don't mention what OS you're running. If you're on Windows (especially 32-bit) I often see problems allocating more than, say, 800MB as heap, regardless of how much actual memory you have available. This isn't really Windows bashing: the Windows JVM wants to allocate all of its heap in a contiguous chunk and if it can't it fails to start.
I think Java maximum memory on Windows XP does a good job of explaining the problem and how you might try to solve it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With