Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio: "Could not reserve enough space for object heap" when making module

I tried to use Android Studio 0.1 to build a small project for practice, but when I make my module, Android Studio says:

Android Dex: [(Module Name)] Error occurred during initialization of VM
Android Dex: [(Module Name)] Could not reserve enough space for object heap

I'm using Windows 7 64-bit, JDK 1.7, with 8GB RAM. I'm not familiar with gradle and don't have an idea how to workaround it. My another almost same PC does not have this problem.

I have tried to modify studio.exe.vmoptions in bin folder, and can see the right-down corner change to 742M when I set -Xmx768M. But the error still occurs. Also, if I want to set a larger value like -Xmx2G, the studio.bat shows:

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.

Then the Android Studio just does not start up.

Is there a way to make my Android Studio usable? Thank you very much.

like image 752
Romulus Urakagi Ts'ai Avatar asked May 19 '13 06:05

Romulus Urakagi Ts'ai


2 Answers

For 64 bit users.

  1. Click Start.
  2. type Environment.
  3. Click Edit System Environment Variables.
  4. A dialog will pop up, click the button labeled Environment Variables.
  5. Locate JAVA_HOME set it to C:\Program Files\Java\$YOUR_JAVA_VER where $YOUR_JAVA_VER = jdk1.7.0_21. (You can check your Java version by actually navigating to C:\Program Files\Java\ and looking for your JDK.)

If there is no JAVA_HOME you may need to create it.

like image 128
Victorio Berra Avatar answered Oct 06 '22 00:10

Victorio Berra


For Android studio - Solution here.

like image 33
Faiz Siddiqui Avatar answered Oct 05 '22 23:10

Faiz Siddiqui