Search code examples
androidcordovaintellij-ideagradlevisual-studio-2015

Getting Gradle error "Could not reserve enough space for object heap" constantly in Intellij IDEA


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.


Solution

  • Installing 64 bit Java solved it for me