16

Android Studio uses 100% CPU when I'm just coding, even if I type a single word CPU use raises to the 100% and comes to back normal, and if I keep typing it takes 100% CPU all the time.

What I have tried is :

  • File > Invalidate cache and Restart
  • Change max heap size for android studio by editing VM options
  • "Power Save Mode" it runs perfectly when it is turned on. but it also disables some useful features of IDE and I don't want to disable it.
  • removed .android and .AndroidStudio3.0 folder from c:\users\username\
  • Android Studio plugins are set to default. no extra plugins are added. I tried disabling a plugin that can be disabled like Git and SVN but it's still same

I'm running windows 7 64-bit OS and Android Studio 3.0 and OS which I re-installed yesterday. I did not install the JDK - Android Studio is using default OpenJDK.

I've searched on internet but it did not help. any help would be appreciated.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Prashant
  • 1,593
  • 1
  • 17
  • 32
  • What is your system configuration? – Khemraj Sharma Nov 16 '17 at 17:46
  • It's laptop, Core 2 Duo with 4 GB of RAM. there was no problem before. it started after i re-installed windows. – Prashant Nov 16 '17 at 17:47
  • 1
    You should beware of it. Android studio is very heavy tool for Core 2 duo. I suggest you to increase your Ram by 8gb for better performance. I am also posting recommended config. – Khemraj Sharma Nov 16 '17 at 17:53
  • @Khemu yes and I understand that AS is resource intensive and my current system configuration is low for that. But AS should not use all CPU time for just typing. as i said the problem started after i re-installed windows there must be some other issue. and yes i will try the config that you'll post. TQ – Prashant Nov 16 '17 at 18:00
  • I also faced it and i just killed my java.exe from task manager. and it worked always. – Khemraj Sharma Nov 16 '17 at 18:03
  • 1
    Do you get the same issue if you use IntelliJ community edition (its free)? – petey Nov 16 '17 at 18:15
  • Do you see the same issue on a new Android Project? – Jon Nov 16 '17 at 18:27
  • @Khemu killing java.exe will help when we want to free up some memory. but it will increase first build time too. – Prashant Nov 17 '17 at 03:12
  • @Jonathan , just created new project and i get the same issue. – Prashant Nov 17 '17 at 03:12
  • @petey , No, I haven't tried it yet. but i will try it and will let you know if it helps – Prashant Nov 17 '17 at 03:14
  • did you ever try IntelliJ community edition? – Jon Nov 20 '17 at 21:16
  • @Jonathan sorry for late reply, yes i tried but it showed same issue. – Prashant Nov 21 '17 at 05:55
  • @Prashant android studio requires 8 gb ram to run smoothly , if you cannot afford it , click file->Power Save Mode , it will decrease usage but it wont give you any hints and wont check for lint errors . – Manohar Nov 22 '17 at 12:40
  • did you try everything mentioned on this thread https://stackoverflow.com/questions/19986498/android-studio-using-100-cpu-at-all-times-no-background-processes-appear-to – Bhanz Nov 24 '17 at 13:27
  • @Bhanz nothing worked except "Power save mode" , which disables functinalities – Prashant Nov 24 '17 at 15:49

6 Answers6

4

Unfortunately, the new Android studio do require RAM.

" You can download Android Studio 1.5.2 which should support 2Gbs of Ram And I would also recommend you to move to Linux Ubuntu OS from Windows 10 as you can set a portion of your Hard disk space as Ram memory(4gbs recommended) during installation(Search on Youtube on how to do that)." Source quora:

fhery021
  • 317
  • 2
  • 7
  • Also consider [this link](http://techzog.com/development/android-studio-high-ram-usage/). Fine tuning for Android Studio. Hope it will help – fhery021 Nov 22 '17 at 09:15
  • Thanks for the resp, i will try that too. I am running windows 7 and also tried ubuntu 16 LTS and 14 LTS , however Ubuntu 16 is having many bugs and 14 do not support my hardware well. i have enabled page file in windows (swap in ubuntu as you said). – Prashant Nov 22 '17 at 10:35
  • 1
    If nothing works (page file, heap memory reduce, nor installing an older version of Android Studio), consider Eclipse as an alternative (I know Android Studio would be the preferred one but usually Eclipse consumes less memory and CPU). Also [here](https://developer.android.com/studio/intro/studio-config.html#low_memory) you have the official configuration instruction from Google. Maybe you will find something not already set in your environment. – fhery021 Nov 22 '17 at 11:02
  • unfortunately older versions are no longer available for donwload. – Prashant Nov 24 '17 at 15:50
  • 1
    Windows also supports the page file like linux's swap file, doing that won't help much as notebook's HDDs are slower, it will only help it swap/pagefile is stored on SSDs – Prashant May 29 '18 at 09:58
2

It seems your systems config is low. as Android studio cares of itself for CPU uses so it gives its best.

Reasons being

  • You have Core 2 duo that is too low for Android Studio.
  • You have 4gb Ram, that is too low again.

If you work on some large project then 2gb of ram is necessary for Android Studio. and Java takes unexpected upto 4gb or more.

Solution

  • Increase ram by 8gb and processor at least intel i3

  • kill java or invalidate cache and restart if you get stuck of hanging your android studio.

Here is my CPU uses that goes upto 3gb for Android Studio and upto 4gb for Java.

enter image description here

The recommended hardware requirements for Android Studio are:

Microsoft® Windows® 8/7/Vista (64-bit Recommended)

Intel i5 4th-5th gen processor.

6 GB RAM

2 GB hard disk space + at least 1 GB for Android SDK, emulator system images, and caches

Optional for accelerated emulator: Intel® processor with support for Intel® VT-x,

As Java uses it’s own Machine known as JVM(Java Virtual Machine) for program compilation and it has some complex tasks like generate classes then verify byte code and then execute program with JIT(Just In Time)

And as Android has Natively developed in Java the slow compilation will be the issue i presume. But with new Android Studio feature known as “Instant Run” compilation and development of Android apps made more easy.

As i am developer of Android apps, I use

Intel i5 6th gen 2.70 Ghz processor

12 GB of RAM (8GB in first slot and 4 in Second Both DDR3) 1 TB of Hard Drive Nvidia G-Force 940M 2 GB of Dedicated GPU for running Adobe After-Effects, Maya and Unity like Software which needs Dedicated GPU. That’s all and Still Android Studio sometimes Lags with such high performance Hardware with the more complex and big apps(Complex Projects).

I think if you are going to buy a hardware and use it for at-least 3 years get the exact specs i have (or similar), However if you are frequent hardware changer use specs i mentioned first.

And for Emulator use Genymotion as it is way faster then the emulator which Android provides. Or use some other alternatives like Memu, Blustacks, Andy etc.

Khemraj Sharma
  • 57,232
  • 27
  • 203
  • 212
0

Try to add more Heap memory for Android Studio, go to Help -> Edit Custom VM Options... and set -Xmx2g (depends on your project size), after restart AS.

vrudas
  • 66
  • 5
0

Did you try to set the power plan to best performance instead of balanced plan. This may consume the battery but may solve this problem.

0

If you have any USB drives laying around, try using those for ReadyBoost. It may help you.

For the uninitiated, ReadyBoost, in a nutshell supposedly makes your WINDOWS PC faster by using how much ever space you dedicate it to (aka extra RAM)

For the uninitiated, to set it up,

  1. Plug your USB / SD /WHAT EVER DIGITAL STORAGE you have into your computer
  2. Go into Windows Explorer > This PC > Right click on Whatever storage you have plugged in
  3. Select Properties in the Context (right click) menu
  4. Go to the ReadyBoost tab
  5. Choose what to do with it
flash76
  • 382
  • 3
  • 23
0

Go to: Preferences > Version Control > Background. Now listed under 'Background Operations' are 6 options. I disabled the first three options which are:

Perform update on VCS in background, Perform commit to VCS in background, Perform checkout to VCS in background.

This reduces lot of power consumption of the CPU

Ramya Bm
  • 27
  • 2