Increase Performance Android Studio

Solver 1

You can speed up your Eclipse or Android Studio work, you just follow these:

  • Open your single project
  • clean your project after running your app in emulator every time
  • use mobile/external device instead of emulator
  • don't close emulator after using once, use same emulator for running app each time
  • Disable VCS by using File->Settings->Plugins and disable the following things :
    1. CVS Integration
    2. Git Integration (Git & Github)
    3. Google Cloud Tools for Android Studio
    4. Subversion Integration
    5. Firebase (Optional)

I am also using Android Studio with 4-GB installed main memory but following these statements really boost my Android Studio performance.

Solver 2

Android Studio (up to 1.5GB)

The IDE's JVM is configured to have a max heap size. You can see this in the lower-right corner of the main interface:

Android Studio showing 725M max heap size

You can reduce this by editing the memory-related settings in the .vmoptions file . For example, I changed my max heap size to 512MB:

-Xmx512m

Unfortunately, I found that lowering this value increases the frequency of Android Studio temporarily freezing, perhaps to do its garbage collection.

Gradle (up to 1.5GB)

Gradle can also use a lot of RAM after developing for a while. Windows just shows it as Java(TM) Platform SE Binary:

Windows 8.1 Task Manager showing "Java(TM Platform SE binary" using 1,460.5 MB of memory

You can fix this by changing the Gradle JVM options. You can do this on a per-user basis by editing gradle.properties :

  1. Open the gradle.properties file, creating it if it doesn't exist:
    • Windows: %USERPROFILE%\.gradle\gradle.properties
    • Linux/Mac: ~/.gradle/gradle.properties
  2. Update the org.gradle.jvmargs property, creating it if necessary. I set mine to this:

    org.gradle.jvmargs=-Xmx256m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
    

I haven't noticed any difference in build performance for my small project with the max heap size set to 256MB (-Xmx256m).

Note that you might need to restart Android Studio so the old Gradle process is killed; otherwise you might end up with both running at the same time.

Emulator

Regarding the emulator taking up a lot of your RAM, your screenshot shows it taking about 800MB. You can choose how much RAM to allocate to the emulator:

  1. Edit the AVD
  2. Press Show Advanced Settings
  3. Reduce the value of RAM

Android Virtual Device RAM configuration

Definition


Android Studio has recently published an official guide for low-memory machines: Guide

If you are running Android Studio on a machine with less than the recommended specifications (see System Requirements), you can customize the IDE to improve performance on your machine, as follows:

  • Reduce the maximum heap size available to Android Studio : Reduce the maximum heap size for Android Studio to 512Mb.

  • Update Gradle and the Android plugin for Gradle : Update to the latest versions of Gradle and the Android plugin for Gradle to ensure you are taking advantage of the latest improvements for performance.

  • Enable Power Save Mode : Enabling Power Save Mode turns off a number of memory- and battery-intensive background operations, including error highlighting and on-the-fly inspections, autopopup code completion, and automatic incremental background compilation. To turn on Power Save Mode, click File > Power Save Mode.

  • Disable unnecessary lint checks : To change which lint checks Android Studio runs on your code, proceed as follows: Click File > Settings (on a Mac, Android Studio > Preferences) to open the Settings dialog.In the left pane, expand the Editor section and click Inspections. Click the checkboxes to select or deselect lint checks as appropriate for your project. Click Apply or OK to save your changes.

  • Debug on a physical device : Debugging on an emulator uses more memory than debugging on a physical device, so you can improve overall performance for Android Studio by debugging on a physical device.

  • Include only necessary Google Play Services as dependencies : Including Google Play Services as dependencies in your project increases the amount of memory necessary. Only include necessary dependencies to improve memory usage and performance. For more information, see Add Google Play Services to Your Project.

  • Reduce the maximum heap size available for DEX file compilation : Set the javaMaxHeapSize for DEX file compilation to 200m. For more information, see Improve build times by configuring DEX resources .

  • Do not enable parallel compilation : Android Studio can compile independent modules in parallel, but if you have a low-memory system you should not turn on this feature. To check this setting, proceed as follows: Click File > Settings (on a Mac, Android Studio > Preferences) to open the Settings dialog. In the left pane, expand Build, Execution, Deployment and then click Compiler. Ensure that the Compile independent modules in parallel option is unchecked.If you have made a change, click Apply or OK for your change to take effect.

  • Turn on Offline Mode for Gradle : If you have limited bandwitch, turn on Offline Mode to prevent Gradle from attempting to download missing dependencies during your build. When Offline Mode is on, Gradle will issue a build failure if you are missing any dependencies, instead of attempting to download them. To turn on Offline Mode, proceed as follows:

    • Click File > Settings (on a Mac, Android Studio > Preferences) to open the Settings dialog.

    • In the left pane, expand Build, Execution, Deployment and then click Gradle.

    • Under Global Gradle settings, check the Offline work checkbox.

    • Click Apply or OK for your changes to take effect.

Another tweak

  1. in Android Studio settings > compile enable checkbox Compile independent modules in parallel.
  2. Under Help > Edit Custom VM Options
  3. -Xms1024m
    -Xmx4096m # <------ increase this to most of your RAM
    -XX:MaxPermSize=1024m
    -XX:ReservedCodeCacheSize=440m
    -XX:+UseCompressedOops
    -XX:-HeapDumpOnOutOfMemoryError
    -Dfile.encoding=UTF-8
    
  4. Android studio 3.5 makes easier to change same of those values.
  5. Preferences > Appearance & Behavior > System Settings > Memory Settings
    

Comments

Popular posts from this blog

Install deb package via Termux

How to Make Blogger Safelink Converter v3

List of weapon buff materials, effects and how it can be durango wild lands