How to speed Android Studio in Linux by changed VM Options

After installing Android Studio 4.1 on Linux, one of the biggest issue was speed of Android Studio at startup. To improve speed vmoptions64 or vmoptions needs to contain the setof lines in blue below. You can change the file using a text editor as follows by opening a terminal window:

$ mousepad ~/.AndroidStudio4.0/config/studio64.vmoptions <enter>

or changing it using Android Studio menu option Help-> Edit Custom VM Options.

Add the following lines to the file, save it and restart Android Studio to see the performance improvement.

-Xms128m
-Xmx2048m
-XX:ReservedCodeCacheSize=440m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-XX:CICompilerCount=2
-XX:+UseCompressedOops
-XX:-HeapDumpOnOutOfMemoryError
-Dfile.encoding=UTF-8
-Dsun.io.useCanonPrefixCache=false
-Djava.net.preferIPv4Stack=true
-Djdk.http.auth.tunneling.disabledSchemes=""
-Djdk.attach.allowAttachSelf=true
-Dkotlinx.coroutines.debug=off
-Djdk.module.illegalAccess.silent=true
-Djna.nosys=true
-Djna.boot.library.path=
-Dawt.useSystemAAFontSettings=lcd
-Dsun.java2d.renderer=sun.java2d.marlin.MarlinRenderingEngine
-Dsun.tools.attach.tmp.only=true

Note -Xmx2048m can be changed to even -Xmx4096m. But it all depends on the RAM of the computer.

Restart Android Studio.

Next, in File -> Settings -> Appearance & Behavior -> System Settings -> Memory Settings:
IDE Heap Size Settings = 4096 MB

Gradle daemon max heap size = 1536 MB
Kotlin daemon max heap size = 2048 MB

Restart Android Studio.

Next, select File -> Settings -> Appearance, look for Windows Options -> Animate Windows and uncheck the box. Then look for Window Options -> Show Memory Indicator. Check the box. You will now find the memory used and total memory in the bottom right corner of the Android Studio window.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s