CPU utilization is going 200% and above when I am ...
# android
c
CPU utilization is going 200% and above when I am working with Android Studio, How can over come this ?
g
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
Here is the response of jps -mv
g
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
I am building project , every time I try to run , takes about 5 minutes
g
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
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
Makes sense, Gradle tries to consume everything what is available
also check that you have enough memory and not in swap
c
I have 16gb RAM , processor is core i5
g
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
Here it is
g
Tight, but looks mostly fine
c
how much you would think should be available for swap size
g
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
oh .. but it has taken 2 .6 gb size
g
yes, but it’s about 15% of your memory
c
Let me go around all the possible options , find out what exactly causing this issue
g
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 %)