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

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.

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:

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.
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.

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.

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.

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,
Plug your USB / SD /WHAT EVER DIGITAL STORAGE you have into your computer
Go into Windows Explorer > This PC > Right click on Whatever storage you have plugged in
Select Properties in the Context (right click) menu
Go to the ReadyBoost tab
Choose what to do with it

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

Related

HoloLens 2 Emulator visual updates extremely slow

I installed the latest version of the HoloLens 2 Emulator (10.0.20348.1501) on my Windows 10 Pro machine. I have 32GB of RAM, 11th Gen Intel 8 Core CPU, Nvidia 3080 (mobile) graphics card.
Initially I thought that the HoloLens emulator was super slow (an input such as trying to move the pointer can take 10, 20, 30 seconds to show up and sometimes doesn't even show up).
But upon testing some more, I've realized that my inputs are going through immediately (as I can tell from the sound feedback), it's just the visual feedback which is not updating. This testing is just inside the OS (without trying to launch an app I developed).
Any ideas what could be going on? In the performance monitoring tool, everything looks fine.
In the end, the only way to fix it, was to disable graphics switching in the BIOS, and set to Discrete only - despite the fact that the Nvidia GPU Activity shows that the GPU turns on when I launch the emulator.
If the emulator takes 10 seconds to update the graphic, there should be configurations issues. Based on my test, though I cannot say it works fluently in my PC, the HoloLens 2 emulator runs at around 15 fps. There is delay but should be work fine for testing. (I am running it with Nvidia 1080 (mobile), with a much older CPU than yours.)
Please check the document on Using the HoloLens Emulator - Mixed Reality | Microsoft Docs and make sure you have configured your computer properly.
In BIOS
Intel VT -> enabled
Intel VT-d -> disabled
Hardware-based Data Execution Prevention (DEP) (or any Intel data protection related feature, display name could be varied) -> disabled
In Windows
After BIOS configuration is done, completely shut down your PC, then boot. (Directly reboot may not apply changes).
Run dxdiag to check:
DirectX 11.0 or later (12.0 in my PC)
WDDM 2.5 graphics driver or later (3.0 in my PC)
Hyper-V Checking
Enable it if it is not. Reboot is required.
If it is already enabled. Disable it -> reboot the PC -> enable it again -> reboot
Others
For the laptop, make sure the power supply is plug-in and it is not in power-save mode. Check the GPU payload (around 36% in Nvidia 1080 mobile)
Then you may run the emulator again to see if this issue still exists.

Android Studio consuming all the system RAM and swap mermory

I have ubuntu20.04LTS installed on my desktop
Android Studio version 4.1.3
Intel Pentium G645 # 2.90 Ghz dual core
6 GB of RAM
1.5GB of swap
I am learning android but my projects are not that heavy but then too my pc hangs even if I open android studio alone it just starts consuming RAM and swap memory slowly
What can I do to fix this problem please help.
Edit custom VM Options
Add or change the value of -Xmx. Units are MB (specified as m) or GB (specified as g). Here I tell it to only use 2 GB RAM:
-Xmx2g
JetBrains totally reworked the user interface recently, in fact the UI is quite fluid between major releases. Android Studio is based on the same core as IntelliJ IDEA, and for the current version you would clock on the settings icon at the lower left of the signon screen, then you will see VM settings.

Android Studio Quickboot/Snapshot not supported error?

I am Facing this error recently. Everything was fine i was learning android studio and suddenly out of nowhere this hit me up.
****Emulator: Warning: Quick Boot / Snapshots not supported on this machine. A CPU with EPT + UG features is currently needed. We will address this in a future release.****
This error made me to delete my virtual device and create a new one. Then it became too slow to start and run the applications. I am running an i5 - 4570 with 8 gigs of ram and a NVIDIA GT 610. I have installed HAXM and virtualization is enabled.Please help me through this.
Kudos.
This error means that your CPU do not have right configuration the INTEL VTX technology in your PC.
Android recommend this steps:
https://developer.android.com/studio/run/device
Is more reliable in some cases use a physical device via USB instead of emulator.

What is the status of Android Studio 3.5 running on Win10 with Ryzen 5 (or 7) CPU?

Really trying to not create a duplicate.
I've read the closest SO on this and it is quite old:
Android Studio and Ryzen CPU?
It's time to upgrade my hardware since my i7, 8GB RAM laptop can no longer run Android Studio and the emulator at the same time (major memory issues). Unfortunately, my laptop can only go to 8GB.
I am definitely considering a Ryzen 5 or 7 since I can save so much $$$ (compared to similar Intel choices).
On Ryzen, can I run the normal HAXM emulator? The one I'm used to running on my i7? Or do I have to run something different?
Does anyone have comparison stats? My i7 starts the emulator just about instantly on my i7. But I can no longer run the emulator and android Studio (AS) at the same time (due to RAM being eaten up by AS and associated Java runtimes).
Is running on the Ryzen not solid? Am I going to see a lot of crashes? Is it going to be so slow it drives me crazy? If not I'd rather pay the extra for the Intel chip?
Hope someone out there is an Android dev and has experience to share.
Win10 Version?
Also, I just read the requirements for Hyper-V. I'm running Windows Home edition. Do I need Windows Pro or Enterprise to run with Ryzen 5/7? Will I be required to use Hyper-V?
The following is from : https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v
Windows 10 Enterprise, Pro, or Education
64-bit Processor with Second Level Address Translation (SLAT).
CPU support for VM Monitor Mode Extension (VT-c on Intel CPUs).
Minimum of 4 GB memory.
The Hyper-V role cannot be installed on Windows 10 Home.
I found the following information from July 09, 2018 (a while ago and AS 3.2 was out) that seems to indicate that :
1. Android emulator is supported and will run with AMD Ryzen chips
2. You will need to turn on Windows HyperVisor Platform (which should be available via Windows 10 Home)
https://android-developers.googleblog.com/2018/07/android-emulator-amd-processor-hyper-v.html
It also states (my emphasis shown where I am confused -- not sure what Hyper-V running at same time gives me) :
If you want to use Hyper-V at the same time as the Android Emulator
on your Intel processor-based computer, you will also need the same
Android Studio and Android Emulator versions as listed above, but with
the additional requirements:
Enable via Windows Features: "Hyper-V" - Only available for Windows 10 Professional/Education/Enterprise
Intel Processor : Intel® Core™ processor that supports Virtualization Technology (VT-x), Extended Page Tables (EPT), and
Unrestricted Guest (UG) features. Additionally VT-x needs to be
enabled in the BIOS.
More Info - Definitive Answer
My son has a machine with Gigabyte m/b and a Ryzen 5 2600x and we installed Android Studio 3.5 and made the appropriate changes tonight.
The board / CPU supports SVM (virtualization technology) so we made
that change in the BIOS.
Next we turned on the Win10 setting for Windows HyperVisor Platform.
We downloaded an x86 Oreo image via Android Studio / AVD Manager and ran it and it runs very fast and smoothly on that machine (16GB RAM).
We didn't see any problems. Loaded up a basic template app and deployed it to the Android VM and it ran great. It all looks good to me. Support for Ryzen seems to be just fine. I will be buying a board and Ryzen just like his.
Update - 2020-03-23
I did purchase the Gigabyte mainboard and the Ryzen 5 2600x and I've been running it for over 6 months now and running current versions of Android Studio (keeping it updated) during that time.
I have 16GB RAM and the CPU can run Android Studio and at least two emulators running at the same time with no problems at all.
Ubuntu Linux / Windows 10 Home Edition Dual Boot
I dual boot my machine running Ubuntu and Win10. I run Ubuntu 90% of the time because Android Studio runs so smoothly on it, but I also boot in to Win10 and Android Studio runs fine there too. (Home edition works fine.)
This confirms that the AMD processors work completely fine running the Android emulators.

How do I boost up my android studio's emulator on mac?

Android studio's emulator takes like ages to start and also crashes sometimes and at times does not show output, is very very slow.
OS X Yosemite
version 10.10.1
MacBook Pro (15-inc, late 2008)
Processor 2.4 GHz Intel core 2 Duo
Memory 8 GB 1333 MHz DDR3
Startup Disk Untitled
Graphics NVIDIA GeForce 9600M GT 256MB
If i remember correcly your MacBook do not support Hardware Accelerated Execution Manager becouse the cpu is quite old :-( (mine is too) so the default android emulator will be so so slow and there is no way to fix it
Yes you can tweek some parameters and maybe gain a second but it would be very marginal gain.
I use Genymotion is realy fast and run well on ald machines, give it a try. Is commercial product. It han the big disadvantage that there is no images with google play services.
Otherwise there is a way to run android images on "Oracle VM VirtualBox" but this way is not so easy, is hard to find a good android image and setup the envirnoment. install Android in VirtualBox
ps. if you haven't done this already upgrade hd to an ssd , it helps a lot

Resources