As android developers we love Android Studio since it makes our lives much easier. If you are a developer form an eclipse (Hats off for the big boss) era I don’t want to say anything. You may feel Android Studio like heaven. But you should Fine-tune Android Studio properly to get the full benefit.
With the IntelliJ engine and gradle android development comes a long way. But you know, gradle is in fact quire resource hungry guy. Even for a simple “Hello World” application the daemon might use very well up to 150MB or even more. When it comes to multi-module production level application we should provide enough resources for gradle.
You may have already experienced slowness or unresponsiveness in Android Studio with the latest updates (Mostly 3.1.x). When the default memory allocation of Android Studio is not enough for your project you have to face this definitely. You can fine-tune Android Studio by allocating enough resources.
I’m going to show how to Fine-tune Android Studio by tweaking a few JVM options. You can get a smooth experience by following the below steps. What you need to do is create a studio.vmoptions file in the Android Studio settings folder. (For 64-bit version it’s studio64.vmoptions )
Click Help > Edit Custom VM Options to open your studio.vmoptions file. (or you can create the file manually in side bin directory in android studio installation directory e.g. : C:\Program Files\Android\Android Studio)
Then add below configuration to studio64.vmoptions file
- Runs JVM in Server mode with more optimizations and resources usage
It may slow down the startup, but if you usually keep IDE running for few hours/days
JVM may profile and optimize IDE better. Feel free to remove this flag.
- Sets the initial size of the heap, the default value is 256m
- Max size of the memory allocation pool, the default value is 1280m
- Sets the size of the allocated class metadata space that will trigger a GC the first time it is exceeded, the default max value is 350m
Now your studio64.vmoptions file should look like this.
-server -Xms1G -Xmx2G -XX:MetaspaceSize=512m
Restart the Android Studio and feel the difference.
Happy coding 🙂