How to increase the memory of Android Studio IDE?

3

Lately I have developed for Android, and I have noticed that the IDE Android Studio takes a long time to load and start.

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

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

    
asked by anonymous 31.05.2016 / 20:57

3 answers

3

It is not advisable to edit any files in the Android Studio installation folder, because any changes will be lost when the IDE is upgraded.

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

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

Beginning with version 2.0 you no longer need to make these changes manually.

Android Studio offers the Edit Custom VM Options menu, which will automatically create the file in the right location in the Help menu.

Thefileopensinataboftheeditorsoitcanbeedited.

TheattributefortheamountofmemorythatAndroidStudiousesis-Xmx1280m,inthiscase1280Mb.

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

More info on Configure Android Studio .

    
06.09.2016 / 00:16
3

Configuring memory properly for the Android Studio IDE

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

Android Studio, by default (default), is configured with low memory, so it slows down 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 it?

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

** Important Notice **

  

Before editing the files studio.exe.vmoptions e    studio64.exe.vmoptions , know that they are protected files,   so it's not enough to just edit and save, because it will give Android   Studio does not allow editing and saving of the direct file in the bin folder,   so what you're going to do is right click on top of the   file, select Open with Notepad, edit the file, and the   time to save, you save the file like this - > Name:    studio.exe.vmoptions , Type: Todos os arquivos(*) and save it to your    área de trabalho and after saving, that's where you copy this   new file that is on your desktop and paste it in the 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 Sim, desejo substituir o arquivo antigo pelo novo e   now everything is ok, you have updated the file by   replacement!

Look at the file studio.exe.vmoptions below, probably it should be with very low values, like this:

#
# *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 snippet:

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

Once you have modified the above excerpt, save the file in your área de trabalho , like this:

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

Once you have saved, it is there that 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.

Look at the file studio64.exe.vmoptions below, probably it should be with very low values, like this:

#
# *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 snippet:

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

Once you have modified the above excerpt, save the file in your área de trabalho , like this:

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

Once you have saved, it is there that 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 to have helped, just update the files and start the Android Studio IDE, and you'll see that Android Studio is starting much faster!

    
31.05.2016 / 22:04
1

This solution worked for me, but the file in version 3.1 of android studio is now called studio64.exe and its content looks 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 modified for 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 noticed that the loading time for a project fell by half. I have not made any measurements regarding execution yet.

    
29.08.2018 / 23:00