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?

Solution 1


Android Studio 2.0 and above, you can create/edit this file by accessing "Edit Custom VM Options" from the Help menu.

-------ORIGINAL ANSWER--------

Open file located at


Change the content to


Xmx specifies the maximum memory allocation pool for a Java Virtual Machine (JVM), while Xms specifies the initial memory allocation pool. Your JVM will be started with Xms amount of memory and will be able to use a maximum of Xmx amount of memory.

Save the studio.vmoptions file and restart Android Studio.


If you changed the heap size for the IDE, you must restart Android Studio before the new memory settings are applied. (source)

Solution 2

I looked at my Environment Variables and had a System Variable called _JAVA_OPTIONS with the value -Xms256m -Xmx512m, after changing this to -Xms256m -Xmx1024m the max heap size increased accordingly.

Solution 3

Or, you can go to your android-studio\bin folder and change these -Xmx and -Xms values in studio.exe.vmoptions or studio64.exe.vmoptions files (depending on which version you are running).

Solution 4

You should not edit any files in the IDE installation directory. Instead, you can customize the attributes by creating your own .properties or .vmoptions files in the following directories. (This has been possible on some platforms before, but it required you to copy and change the entire contents of the files. With the latest changes these properties are now additive instead such that you can set just the attributes you care about, and the rest will use the defaults from the IDE installation).

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.

Solution 5

I increased my memory following the next Google documentation:

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\

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.

Solution 6

If you are using MAC BOOK, this option is available inside Applications -> Right click Android Studio then choose Show Package contents -> bin.


open -e /Applications/Android\

Then increase Xmx value


Now your Android Studio will be super-fast.

Solution 7

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.exe.vmoptions file & Save it.

file location : "\Users\username\.AndroidStudio3.**\config\"


Solution 8

You can try any one of the following

1)Change the file and change the heap size as per your requirement.

If org.gradle.jvmargs=-Xmx2048M is not sufficient then change to 4096 as given


2)"Edit Custom VM Options" from the Help menu.

It will open studio.vmoptions / studio64.exe.vmoptions file.

Change the content to






Save the the file and restart Android Studio.

Solution 9

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 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:


Replace or change it and you will get all the RAM you need.


Solution 10

I tried the _JAVA_OPTIONS thing but it wasn't working for me still.

In the end, what worked for me was the following:

  • Launching studio64.exe instead of the studio.exe(I've got a 64-bits machine).
  • Add/Change the following values in "studio64.exe.vmoptions":


Solution 11

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:

Solution 12

First check how much memory allocated for your android studio to check that follow this steps :

File -> Settings->Appearance & Behavior->Appearance

then check the show memory indicator option like below image red highlighted part

In my case my RAM is 12Gb so i have allocated memory for android studio 6gb .To edit that follow this steps

Help->Edit custom VM options


In my case, i have set it 6gb because my pc ram is 12 GB. Its upto you how much memory you want to allocate to your android studio

Solution 13

This is how you change the heap size currently in Android Studio 3.6.1

On Windows in your Android Studio:

  1. Select File -> Settings (the popup below will be displayed)

  1. Select Appearance & Behavior
  2. Select System Settings
  3. Select Memory Settings

Then change the IDE Heap Size settings to your desired value

On Mac:

  1. Select Android Studio
  2. Select Preferences

The same pop up will appear. However, this time on the Mac its called Preferences.

Follow the same steps as the Windows version of Android Studio to adjust the heap size wants the Preferences dialog has been displayed

Solution 14

On Mac OSX one can easily change heap size by going to first menu item, Android Studio > preference > System Settings (left menu) > Memory Settings and change heap size there in the dialog.

Solution 15

On Windows 7, the configuration files at [INSTALL-LOCATION]\bin seem to be ignored. Per the following Google documentation, the file to be modified should be here: %USERPROFILE%\.AndroidStudio\studio[64].exe.vmoptions

Odd that there is no such file upon a clean install of Android Studio 1.1 from the developer site. And they are in the old (ignored) location. Once I copy the file (studio.exe.vmoptions in my case) over and modify it, the change is respected.

However, the fun doesn't stop there. There's an upper value for -Xmx which may be related to the amount of memory in your system. I just bumped my machine's memory from 4Gb to 16Gb, and assumed I could set -Xmx to 2048m, but I found that if I set it to anything larger than 1500m, Android Studio would silently fail to launch with no indication at all as to why. I have more RAM on the way, so it will be interesting to see if I can increase the value at that point.

I hope this additional information is helpful. While all of the above replies were undoubtedly true at one point (and may still be in some environments), I found that this was the only approach that increased the memory used by AS for me.

Solution 16

Open studio.vmoptions and change JVM options

studio.vmoptions locates at /Applications/Android\ (Mac OS). In my machine, it looks like


Change to


And restart Android Studio

See more Android Studio website

Solution 17

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.

Solution 18

Go in the Gradle Scripts -> and paste this

`org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m`

, if you want to change it to 512. Hope it works !

Solution 19

you are not supposed to modify the bin/studio.exe.vmoptions file, which will be verified during applying update patch.

Solutions are here

copy that file into following location, then change the -Xmx1280m to whatever you want.


%USERPROFILE%\.{FOLDER_NAME}\studio.exe.vmoptions and/or %USERPROFILE%\.{FOLDER_NAME}\studio64.exe.vmoptions



~/Library/Preferences/{FOLDER_NAME}/studio.vmoptions ~/Library/Preferences/{FOLDER_NAME}/


~/.{FOLDER_NAME}/studio.vmoptions and/or ~/.{FOLDER_NAME}/studio64.vmoptions


Solution 20

Had this Xms and Xmx 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.

Solution 21

On Ubuntu, it's straight forward, clicking Help > Edit Custom VM Options . The IDE asks whether to create for you a file, click OK.

An empty studio64.vmoptions file is create and paste the following variables:


Restart the IDE, the Max Heap Size is increased to: 4,062M

Solution 22

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.

Solution 23

IF by changing or creating the .studio.exe.vmoptions doesn't work, then try changing the file and change the heap size as per your requirement.

It really worked for me on my Windows 7 with 4Gb RAM and Android Studio 2.2 install on it.

Working properly with no error and displaying 'Gradle Sync complete'

Solution 24


Solution 25

As of 2022, you may check this link here.


Syntax: %APPDATA%\Google\<product><version>

Example: C:\Users\YourUserName\AppData\Roaming\Google\AndroidStudio4.1


Syntax: ~/Library/Application Support/Google/<product><version>

Example: ~/Library/Application Support/Google/AndroidStudio4.1