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!