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!