So I have a problem with memory allocation. Sometimes it works, and sometimes it doesn't. I've read this thread and tried the advice there multiple times. Sometimes -Xms512m -Xmx768m
works, sometimes -Xms256m -Xmx512m
. I'm sick and tired of having to tweak this setting in IntelliJ under the Build, Execution, Deployment > Build Tools > Gradle > Gradle VM
options setting. Is there no setting that solves this once and for all?
I have 16GB of RAM on my Windows 7 computer, I'm running IntelliJ IDEA EAP 14 build 138.2210.3, 64 bit version. Android Gradle build plugin v0.12.
I'm suspecting gradle is not running in 64 bit mode, or else it would have ~7 GB of free memory to eat from. Why is it not utilizing this?
EDIT:
I got the same error in Visual Studio 2015 with cordova 5.1.1 under Windows 10. See my solution below.
You might get an specific error Could not reserve enough space for 2097152kb object heap in case you are using any tool. It simply means that JVM is not able to acquire 2 GB heap space which is required by the tool by default.
To fix the error "Could not reserve enough space for object heap", add the options "-Xmx<size>m" to set the maximum size for the object heap memory allocation. This must be set large enough to accommodate loading your application into memory, but smaller than your requested total memory allocation by 2GB.
“Could not reserve enough space for object heap” is a specific JVM error that is raised when Java process cannot create the virtual machine due to memory constraints encountered on the running system: java -Xms4G -Xmx4G -jar HelloWorld.
To fix the could not reserve enough space for 2097152KB object heap error message, just change the -Xmx setting to something more conservative such as 512m or 1024m.
I got the same error in Visual Studio 2015 with cordova 5.1.1 under Windows 10.
To solve the issue, set this environment variable:
_JAVA_OPTIONS=-Xmx512M
This Article point me in the right direction. I did change the instructions a littel bit, so they fits to Windows 10.
Hope it helps someone!
Installing 64 bit Java solved it for me
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