26

My 4GB RAM, Intel Core i5 system came down down to its knees with high disk and RAM usage by Android Studio(I can see it in the task manager, nothing else is using the RAM and disk). The gradle build takes about 10-15 mins for a simple project.

Is there any solution?

Atiq
  • 14,435
  • 6
  • 54
  • 69
Chandra Eskay
  • 2,163
  • 9
  • 38
  • 58
  • 1
    My PC is 4GB RAM, core i3, it is not that much slow, check if there is any update you need to install, another thing you should try is running Android studio as admin, I feel it is little smooth with admin. – Prafulla Kumar Sahu Apr 26 '16 at 10:22
  • You need a beefier machine. Yes, its ridiculous. And I think Eclipse, while not great, did a better job of it. But they aren't moving back that way. 8 GB is really the minimum, 16 or more is better. Its pretty fast on my new 64 GB machine. – Gabe Sechan Apr 26 '16 at 10:22
  • One way you can help- don't use an emulator. That's another big chunk of RAM. Use a real device so more RAM can go to the IDE. – Gabe Sechan Apr 26 '16 at 10:23
  • yes, Gabe is right, you can consider using a device in place of emulator . – Prafulla Kumar Sahu Apr 26 '16 at 10:25
  • I don't see why there is a downvote!! Thanks for your solutions, I will buy RAM this weekend. – Chandra Eskay Apr 26 '16 at 10:28

7 Answers7

40

You need to upgrade your PC though but there are few things you can do to make it faster

1. Increase the memory size of Android Studio:

Open the file located at /bin/studio.vmoptions and Change the content from

-Xms128m
-Xmx800m

to

-Xms256m
-Xmx1024m

Xms specifies the initial memory allocation pool. Your JVM will be started with Xms amount of memory and will be able to use a maximum of Xmx amount of memory.

Save the studio.vmoptions file and restart Android Studio.

2. Improve Gradle performance:

Create a file named gradle.properties in

/home/<username>/.gradle/ (Linux)
/Users/<username>/.gradle/ (Mac)
C:\Users\<username>\.gradle (Windows)

and add the line:

org.gradle.daemon=true

This helps a lot, with org.gradle.daemon set to true Gradle reuses computations from previous builds and cache information about project structure, files, tasks etc. in memory so it won’t have to start up the entire Gradle application every time.

Source

Atiq
  • 14,435
  • 6
  • 54
  • 69
  • 1
    All these steps reduced the build time to 37 seconds. That's great performance improvement. Thanks. – Chandra Eskay Apr 26 '16 at 11:08
  • Is it the Gradle Daemon that is making most of the difference? – Hackmodford Oct 07 '16 at 13:49
  • yeah it reuses computations from previous builds and cache information about project structure, files, tasks etc. in memory so it won’t have to start up the entire Gradle application every time. – Atiq Oct 07 '16 at 14:58
  • I reverted the offline work option and didn't really notice a difference. I'm leaving it stock. – Hackmodford Oct 08 '16 at 15:05
  • 1
    The last option is not really necessary it just specifies that the build should operate without accessing network resources. which makes the build somewhat faster. I think i will remove that extra step from the answer to make it better – Atiq Oct 08 '16 at 15:14
  • none of this stuff works for me, I have mbp 2015 8gb, something's not right – TootsieRockNRoll Jul 25 '17 at 14:55
  • studio.exe.vmoptions and studio64.exe.vmoptions showing this folder in my laptop but not able to change the value -Xms256m and -Xmx1024m . always getting this message "please check if this file is opened in another program". how to solve this please guide – Amit Verma Oct 06 '18 at 15:44
  • @AmitVerma make sure `Android Studio` is completely close when editing those files. – Atiq Oct 06 '18 at 16:59
  • @Max closed everything and restart the laptop, but still getting the same message, could you help me, please – Amit Verma Oct 07 '18 at 07:08
3

For me Android Studio slowness has a strong relationship with Task Manager showing a 100% disk usage most of time. I have done three things on my Windows 10:

1 - Disable "Windows Search" service

2 - Disable "Superfetch" service

3 - If you have Google Chrome, go to Settings> Show Advanced Settings ...> Privacy> "Prefetch resources to load pages more quickly" and untick it.

Disk usage is now far lower and Android Studio builds far faster. Hope it will help!

PD: To disable a service pres WindowsKey + R then enter services.msc, find the service > right click > Properties > Init > Disable.

Yoav Feuerstein
  • 1,925
  • 2
  • 22
  • 53
from56
  • 3,976
  • 2
  • 13
  • 23
2

You can avoid this gradle build process, on times gradle build is not necessary.

  1. Use: Run > Edit Configurations.
  2. In this new window, click the green plus icon > Android App.
  3. on the right frame, go to "Before launch", mark "gradle-aware Make", and click the red minus icon. Give this configuration a name, and press "OK" button.
  4. From now on, every time you run your app, you can choose your new configuration, and no gradle build process will be generated.

This may not apply your changes in code on runtime, so you highly recommended to leave the original configuration too for times you need the gradle build.

enter image description here

M. Marmor
  • 390
  • 4
  • 9
1

My 4GB RAM

Get more RAM. Android Studio takes a bit. JVM takes a bit. OS needs some. 4GB is not going to work really.

build takes about 10-15 mins

because it swaps as hell. Get more RAM.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
0

Get expendable RAM upto 8Gb

My laptop has intel i3 processor with 8Gb expendable RAM and I have alloted 4 Gb of RAM to Android Studio only. It runs fast. And one more important thing you may use Genymotion instead of inbuilt Android Studio AVD that is much faster and less system images will be created in your system which will reduce the usage of your hard disk.

HarshitMadhav
  • 4,769
  • 6
  • 36
  • 45
0

For Ubuntu

sudo dpkg --add-architecture i386

sudo apt-get update

sudo apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386

i found here Android Studio fails to build new project, timed out while wating for slave aapt process

Community
  • 1
  • 1
roshan posakya
  • 1,010
  • 10
  • 14
0

Brother I had same problem with my laptop(i3 second generation 8 gb). I have replaced my 500 gb hdd with 500 gb ssd. Now disk active stays just below 3 percent mostly.

aman attri
  • 91
  • 1
  • 8