How to increase memory of Android Studio IDE?

Asked

Viewed 6,012 times

4

Lately I’ve been developing for Android, and I’ve noticed that the Android Studio IDE takes a long time to load and start.

I would like to know, how to increase the memory of Android Studio IDE?

To start the IDE faster and consequently develop faster...

4 answers

6

It is not advisable to edit any file in the Android Studio installation folder, because any change will be lost when there is an update of the IDE.

The correct way is for the changed settings(attributes) to be placed in files created in a folder located in your folder profile(%USERPROFILE%\).

The path of that folder depends on the version of the installed IDE.

Starting with version 2.0 it is no longer necessary to make these changes manually.

Android Studio makes available in the menu Help the option Edit Custom VM Options, which will automatically create the file at the right location.

inserir a descrição da imagem aqui

The file opens in a tab of the editor in order to be edited.

inserir a descrição da imagem aqui

The attribute referring to the amount of memory that Android Studio uses is the -Xmx1280m, in this case 1280Mb.

Source: Configuring Android Studio: IDE & VM Options, JDK, etc.

More info on Configure Android Studio.

5

Configuring the memory properly for the Android Studio IDE

I found the answer in a article, and I took as a basis for my answer and decided to share here at Sopt.

Android Studio, by default(default), comes configured with little memory, and so it gets so slow to start, load, develop and deploy.

The secret here is to use a PC with at least 4GB of RAM and put at least 2GB for Android Studio.

How to do?

In the installation folder, you have a folder called bin(ex: C:\Program Files\Android\Android Studio\bin) and inside there are 2 files: studio.exe.vmoptions and studio64.exe.vmoptions. If you use 32 bit pc, change the studio.exe.vmoptions. If you use 64 bits, change the other. Properly configure xmx, Xms , permsize, caching and other internal.

** Important Notice **

Before editing the files studio.exe.vmoptions and studio64.exe.vmoptions, know that they are protected files, so, do not just edit and save, because it will give error, Android Studio does not allow editing and saving the file directly in bin folder, so, what you’re going to do is right-click on the file, select open with the note pad, edit the file and in the time to save, you save the file so -> Name: studio.exe.vmoptions, Type: Todos os arquivos(*) and save in your área de trabalho and after you’ve saved, that’s where you copy this new file that is on your desktop and glue in bin folder and replaces the previous file, that usual procedure - where the windows will ask Deseja substituir o arquivo antigo pelo novo and you click on Sim, desejo substituir o arquivo antigo pelo novo and now everything is ok, you did the file update by substituting!

View the file studio.exe.vmoptions below, probably it should be at very low values, so:

#
# *DO NOT* modify this file directly. If there is a value that you would like to override,
# please add it to your user specific configuration file.
#
# See http://tools.android.com/tech-docs/configuration
#
-server
-Xms256m
-Xmx750m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=240m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-da
-Djna.nosys=true
-Djna.boot.library.path=

-Djna.debug_load=true
-Djna.debug_load.jna=true
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-XX:+HeapDumpOnOutOfMemoryError
-Didea.paths.selector=AndroidStudio2.1
-Didea.platform.prefix=AndroidStudio

Modify the following excerpt:

-Xms256m
-Xmx2048m
-XX:MaxPermSize=512m
-XX:ReservedCodeCacheSize=512m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=150

After you have modified the above section, save the file in your área de trabalho, in that way:

  • Name: studio.exe.vmoptions
  • Type: Todos os arquivos(*)

Once you have saved, this is where you copy this new file that is on your desktop and paste it into the bin folder and replace the file with the previous one.


View the file studio64.exe.vmoptions below, probably it should be at very low values, so:

#
# *DO NOT* modify this file directly. If there is a value that you would like to override,
# please add it to your user specific configuration file.
#
# See http://tools.android.com/tech-docs/configuration
#
-Xms256m
-Xmx1280m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=240m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-da
-Djna.nosys=true
-Djna.boot.library.path=

-Djna.debug_load=true
-Djna.debug_load.jna=true
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-XX:+HeapDumpOnOutOfMemoryError
-Didea.paths.selector=AndroidStudio2.1
-Didea.platform.prefix=AndroidStudio

Modify the following excerpt:

 -Xms256m
 -Xmx2048m
 -XX:MaxPermSize=512m
 -XX:ReservedCodeCacheSize=512m
 -XX:+UseConcMarkSweepGC
 -XX:SoftRefLRUPolicyMSPerMB=150

After you have modified the above section, save the file in your área de trabalho, in that way:

  • Name: studio64.exe.vmoptions
  • Type: Todos os arquivos(*)

Once you have saved, this is where you copy this new file that is on your desktop and paste it into the bin folder and replace the file with the previous one.


I hope I’ve helped, just update the files now and start the Android Studio IDE, and you’ll see that Android Studio is starting much faster!

2

From Android Studio 3.5 it is possible to configure the amount of memory allocated to the IDE directly in the IDE’s settings.

Way:

Menu File => Settings => Appearance & Behavior => System Settings => Memory Settings.

Select the amount you want to use, apply and restart the IDE for the changes to take effect and it’s OK.

Print shows available memory quantities.

inserir a descrição da imagem aqui

Source:

Android Developers

What’s new in Android Studio 3.5

https://www.youtube.com/watch?v=OJ3K90FpQ6A&list=PLWz5rJ2EKKc_w6fodMGrA1_tsI3pqPbqa&index=3&t=0s

1

This solution worked for me, but the file in version 3.1 of android studio is now called studio64.exe and its contents are like this:

-Xms256m
-Xmx1024m
-XX:ReservedCodeCacheSize=240m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djna.nosys=true
-Djna.boot.library.path=
-da

Having been modified to these values:

-Xms256m
-Xmx2048m
-XX:ReservedCodeCacheSize=512m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=150
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djna.nosys=true
-Djna.boot.library.path=
-da

I realized that the load time of a project has dropped by half. I have not taken measurements with respect to the execution yet.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.