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 increased my memory following the next Google documentation:
http://tools.android.com/tech-docs/configuration
By default Android Studio is assigned a max of 750Mb, I changed to 2048Mb.
I tried what google described but for me the only thing that it worked was to use an environment variable. I will describe what I did:
First I created a directory that I called .AndroidStudioSettings,
mkdir .AndroidStudioSettings
Then I created a file called studio.vmoptions , and I put in that file the following content:
Then I added the STUDIO_VM_OPTIONS environment variables in my .profile file:
export STUDIO_VM_OPTIONS=/Users/youruser/.AndroidStudioSettings/studio.vmoptions
Then I reload my .profile:
source ~/.profile
And finally I open Android Studio:
open /Applications/Android\ Studio.app
And now as you can see using the status bar , I have more than 2000 MB available for Android Studio:
You can customize your values according to your need in my case 2048Mb is enough.
UPDATE : Android Studio 2.0 let's you modify this file by accessing "Edit Custom VM Options" from the Help menu, just copy and paste the variables you might want to keep in order to increase it for everversion you might have on your box.
Android Studio 3.1 has option to edit your customize virtual memory options.
You can go Android Studio > Help > Edit Custom VM Options
Then paste below settings code to studio64.ex.vmoptions file & Save it.
Note: As of Android Studio 2.0, you can create/edit this file by accessing the "Edit Custom VM Options" file from the Help menu.
http://tools.android.com/tech-docs/configuration
May help someone that get this problem:
I edit
studio64.exe.vmoptions
file, but failed to save.So I opened this file with Notepad++ in
Run as Administrator
mode and then saved successfully.you are not supposed to modify the bin/studio.exe.vmoptions file, which will be verified during applying update patch.
Solutions are here http://tools.android.com/tech-docs/configuration
copy that file into following location, then change the -Xmx1280m to whatever you want.
Windows:
%USERPROFILE%\.{FOLDER_NAME}\studio.exe.vmoptions
and/or%USERPROFILE%\.{FOLDER_NAME}\studio64.exe.vmoptions
%USERPROFILE%\.{FOLDER_NAME}\idea.properties
Mac:
~/Library/Preferences/{FOLDER_NAME}/studio.vmoptions
~/Library/Preferences/{FOLDER_NAME}/idea.properties
Linux:
~/.{FOLDER_NAME}/studio.vmoptions
and/or~/.{FOLDER_NAME}/studio64.vmoptions
~/.{FOLDER_NAME}/idea.properties
Note: I now this is not the answer for the post, but maybe this will be helpful for some one that is looking.
If Nothing of this works for you, try on a Mac this to see if helps you, in the last version of Android Studio, the studio.vmoptions is inside the AndroidStudio.app in your Applications folder.
So right click or ctrl click on your AndroidStudio.App and then select show package content the studio.vmoptions is in:
Contents/bin/studio.vmoptions
Replace or change it and you will get all the RAM you need.
Regards.