I've been using Android Studio for 3 months now and one of the apps I started on it has become fairly large. The memory usage indicated at the bottom right of the program says my allocated heap is maxed at 494M.
When I start to change the XML files my memory usage quickly reaches that cap and the IDE crashes with an Out Of Memory error like this.
I've tried to increase the heap size using this but so far there has been no effect.
I've looked at dozens of articles and other questions on how to increase the heap size but none of their answers are working. No matter what I do to the VMOPTIONS or the IDE settings the heap size never increases. I believe I am editting the correct file for the VMOPTIONS because if I purposely give it an invalid command Android Studio complains about it and doesn't start.
I'm using windows 7 - 64 bit and have 16GB RAM. Has anyone else had this problem with Android Studio? And were you able to fix it?
I found on on Windows 7/8 (64-bit), as of Android Studio 1.1.0:
[INSTALL_DIR]\bin\studio64.exe.vmoptions
be used (if it exists), otherwise it would always fall back to%USERPROFILE%.\AndroidStudio\studio[64].exe.vmoptions
If you want the settings managed from
%USERPROFILE%.\AndroidStudio\studio[64].exe.vmoptions
, just delete the one in the installation directory.Open file located at
/Applications/Android\ Studio.app/Contents/bin/studio.vmoptions
Change the content toXmx
specifies the maximum memory allocation pool for a Java Virtual Machine (JVM), whileXms
specifies the initial memory allocation pool. Your JVM will be started withXms
amount of memory and will be able to use a maximum ofXmx
amount of memory.Save the
studio.vmoptions
file and restart Android Studio.More at this post.
---------- EDIT ----------
Android Studio 2.0, you can create/edit this file by accessing "Edit Custom VM Options" from the Help menu.
I tried the _JAVA_OPTIONS thing but it wasn't working for me still.
In the end, what worked for me was the following:
If you are using MAC BOOK, this option is available inside Applications -> Right click Android Studio then choose Show Package contents -> bin.
or
open
-e /Applications/Android\ Studio.app/Contents/bin/studio.vmoptions
Then increase
Xmx
valueNow your Android Studio will be super-fast.
Had this
Xms
andXmx
memory low issue happen to me any time I was working with the XML. I also tried increasing this memory, only to find that it just took a little longer for it to happen again.After getting very frustrated and almost deciding to convert all my current projects back over to Eclipse, which I did not want to do, I figured out what was causing it and was able to repeat this failure and prevent it every time.
While editing the XML in (Text view), and using the "Preview" render view, this causes the loss of memory, every time. Turning off "Preview" and using the Design tab to render the screen only, I am able to use Android Studio all day long, with no crash.
I wish this could be fixed for good, because it would be very nice to use the "Preview" render while editing the XML, however I am glad I can keep using Android Studio.
There are a lot of answers that are now outdated. The desired way of changing the heap size for Android Studio recently changed.
Users should now create their own vmoptions file in one of the following directories;
Windows:
%USERPROFILE%\.{FOLDER_NAME}\studio64.exe.vmoptions
Mac:
~/Library/Preferences/{FOLDER_NAME}/studio.vmoptions
Linux:
~/.{FOLDER_NAME}/studio.vmoptions and/or ~/.{FOLDER_NAME}/studio64.vmoptions
The contents of the newly created
*.vmoptions
file should be:To increase the RAM allotment change
-XmX750m
to another value.Full instructions can be found here: http://tools.android.com/tech-docs/configuration