https://kotlinlang.org logo
#android
Title
# android
c

Chethan

07/13/2020, 9:18 AM
CPU utilization is going 200% and above when I am working with Android Studio, How can over come this ?
g

gildor

07/13/2020, 9:20 AM
check what kind process it is (run
jps -mv
probably it’s Gradle daemon But it shouldn’t consume so much CPU if it idle, but it’s fine if build in process]
c

Chethan

07/13/2020, 9:23 AM
Here is the response of jps -mv
g

gildor

07/13/2020, 9:34 AM
Yes, as you can see it’s Gradle daemon
if you do not build anything, it’s a bug, something causes consuming CPU while daemon is idle, you can try attach profiler and check
c

Chethan

07/13/2020, 9:35 AM
I am building project , every time I try to run , takes about 5 minutes
g

gildor

07/13/2020, 10:14 AM
If you building it’s fine itself, Gradle will run worker on every core of your CPU by default, will try to run them in parallel as possible
so you problem is not CPU consumption, but build time?
First I would recommend to run Gradle Build Scan and check what consumes most of the time, how long GC time and other check other recommendations
anyway, build time is very big topic, it’s a lot of materials in internet
c

Chethan

07/13/2020, 10:15 AM
I am not sure where the problem laying , I can't even browse other application when this is going up to 200% , other application also freezes
g

gildor

07/13/2020, 10:16 AM
Makes sense, Gradle tries to consume everything what is available
also check that you have enough memory and not in swap
c

Chethan

07/13/2020, 10:16 AM
I have 16gb RAM , processor is core i5
g

gildor

07/13/2020, 10:17 AM
it’s not very fast nova days 🙂 But anyway, I mean that you should check that you are not in swap
open memory tab in Mac Monitor and check amount of free memory and swap size
c

Chethan

07/13/2020, 10:19 AM
Here it is
g

gildor

07/13/2020, 10:20 AM
Tight, but looks mostly fine
c

Chethan

07/13/2020, 10:21 AM
how much you would think should be available for swap size
g

gildor

07/13/2020, 10:22 AM
So if you problem just issue that during build Gradle consumes too much resources you have 2 ways: reduce amount of workers (org.gradle.workers.max option) or try to use
org.gradle.priority
option: https://docs.gradle.org/5.0/release-notes.html#gradle-can-be-started-as-a-low-priority-process
but you should understand, it will probably increase your buiild time
how much you would think should be available for swap size
You should have close to zero, so nothing in swap, but actually OS still uses it, so it never 0
c

Chethan

07/13/2020, 10:24 AM
oh .. but it has taken 2 .6 gb size
g

gildor

07/13/2020, 10:25 AM
yes, but it’s about 15% of your memory
c

Chethan

07/13/2020, 10:26 AM
Let me go around all the possible options , find out what exactly causing this issue
g

gildor

07/13/2020, 10:26 AM
anyway, if you are on swap, so OS doesn’t have enough physical RAM it will use disc instead, which makes everything a lot slower (disk obviosly a lot slower)
🤔 1
I would first decide what you trying to fix there %)