FRED CHUNG: Hi, my name is Fred with Android Developer
Relations team.
We're going to talk about improving Android Studio
performance on memory-constrained computers.
Android Studio comes with many features developers
expect from a modern IDE.
For example, lint checks help identify errors
as you are typing source code in the editor.
These developer productivity features
mean increased resource requirements
on the host operating system.
Practically, developers working on complex multi-module
production projects usually have 8 gigabytes of RAM or more.
However, if you're working on a simple project
on a memory-constrained computer with, say, 4 gigabytes of RAM
or less, we're going to go through several things you
could do to make the development experience a bit smoother.
There isn't a definite answer on the minimum specs
needed to run Android Studio because there are so
many factors.
An obvious first step is close any unnecessary applications
on the operating system.
Sorry for those users that keep 20 web browser tabs opened.
For those that have antivirus software running
on the computer, note that build files generated by the IDE
may trigger real-time virus scanning.
This competes for system resources.
If possible, go to your virus scanner configuration
and exclude project build output directories.
Android Studio has a default maximum Java heap
size of 1.2 gigabytes.
If your computer has low RAM, you should correspondingly
reduce the default heap size to something like 512 megabytes.
You can set the desired values using
the xmx key in the studio.vmoption configuration
file by following these instructions.
Note that reducing this value means
shrinking the amount of resources for features
within Android Studio.
For example, performance of the Layout Editor may be affected.
Now let's talk about Gradle, one of the core components
in Android Studio.
Update to the latest versions of Gradle and Android
plugin for Gradle to ensure the latest performance
optimizations are available to your project.
For example, in 3.0, we've improved incremental packaging
with AAPT2.
The snippets here shows specific configurations for the Android
Studio 3.0 beta version.
Your specific installed version may
need a different set of values.
Next, I'm going to talk about several techniques that
have to do with degrading support
and leaving only the bare minimum running.
Note that some of these techniques
could provide performance gain at the expense of code quality,
so you really should use with caution.
Android Studio provides a power save mode.
When turned on, it will disable a number
of background operations that perform lint checks, code
completions, and so on.
There'll be a point in time when you
want to execute any disabled operations manually.
Take lint checks, for example.
You can manually run them through the command line
as shown here.
Some of you may be using the Android Emulator.
On average, it consumes 2 gigabytes of RAM.
If possible, use an actual Android device.
This will help reduce resource load on your computer.
Alternatively, if you must use an emulator,
consider emulated RAM, which will also
decrease virtual memory consumption on your computer.
This configuration can be found under Advanced Settings
in Virtual Device Configuration.
Gradle offline mode is a feature for bandwidth-limited users
to disable downloading of build dependencies.
As a side effect, this could help improve
performance on low RAM machines, since this also
reduces the amount of background processing.
Android Studio offers an optimization
to compile multiple modules in parallel.
On low RAM machines, this feature
will likely have a negative impact on performance.
You can disable it in the Compiler Settings dialog.
I hope this video gives you some ideas on how
to fine-tune Android Studio in your low RAM environments
to make the development experience smoother.
To learn more, check out the Android Developer site.
Thanks for watching.
[MUSIC PLAYING]