Android Studio is slow (how to speed up)?

to sum it up

1) in AndroidStudio’s settings > compile enable checkbox named Compile independent modules in parallel.

2) Under Help> Edit Custom VM Options I have:

-Xms1024m 
-Xmx4096m # <------ increase this to most of your RAM 
-XX:MaxPermSize=1024m 
-XX:ReservedCodeCacheSize=440m 
-XX:+UseCompressedOops 
-XX:-HeapDumpOnOutOfMemoryError 
-Dfile.encoding=UTF-8

P.S. – Some people say Note, instead of VM options, it’s better to combine can be overriden by combining those lines into one line single command in gradle.properties, like this :

org.gradle.jvmargs=-Xms1024m -Xmx4096m ……

3) I have an old dual core with 4GB ram, running ubuntu. Qs command line option I have only --offline (which specifies that the build should operate without accessing network resources). I also enabled the remaining checkboxes and now it’s running ok:

  • Make project automatically

  • Use in-process building Configure on demand

  • Check the AndroidStudio’s settings, under compile that the checkbox Compile independent modules in parallel is enabled.

Under Vmoptions I have

-Xmx2048m -XX:MaxPermSize=1024

I have an old dual core with 4GB ram, running ubuntu. Qs commandline option I have only --offline , which specifies that the build should operate without accessing network resources. I enabled also the remaining checkboxes:

  1. Make project automatically
  2. Use in-process building
  3. Configure on demand

    and it is running ok

Edit

It is possible to provide additional options through studio.vmoptions located at (just replace X.X with version):

  • Windows: go to %USERPROFILE%\.AndroidStudioX.X\studio.exe.vmoptions (or studio64.exe.vmoptions)

  • Mac: ~/Library/Preferences/.AndroidStudioX.X/studio.vmoptions

  • Linux: ~/.AndroidStudioX.X/studio.vmoptions (and/or studio64.vmoptions)

Increasing the value of -Xmx should help a lot. E.g

-Xms1024m
-Xmx4096m
-XX:MaxPermSize=1024m
-XX:ReservedCodeCacheSize=256m
-XX:+UseCompressedOops

will assign 4G as max heap, with initial value of 1G

Edit:

On windows the defaults are stored into C:\Program Files\Android\Android Studio\bin\*.vmoptions. The IDE allows you to tweak those values through Help->Edit Custom VM options (thanks to @Code-Read for pointing it out).

EDIT 2:

Android studio 3.5 makes easier to change same of those values. Just go to:

Preferences > Appearance & Behavior > System Settings > Memory Settings

Leave a Comment