Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio uses 100% CPU while just coding (no builiding)

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.

like image 835
Prashant Avatar asked Nov 13 '17 16:11

Prashant


2 Answers

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:

like image 95
fhery021 Avatar answered Oct 06 '22 19:10

fhery021


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.

like image 20
Khemraj Sharma Avatar answered Oct 06 '22 18:10

Khemraj Sharma