Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle - high CPU use

I recently started to use Android Studio and while I like it a lot, there is one thing that annoys me a lot:

Gradle - it's nice tool and all, but damn it's such a resource hog, also it's just so painfully slow. No matter if I use my 5 years old laptop or my gaming PC, when it's running, other applications go to a full stop (well almost)...

Is there really a reason for a build tool to be so demanding??? I understand compilation can be a slow process but from my experience javac always seemed to be blazingly fast, so it cannot be source of a problem (also building Android apps with ADT was many times faster too)...

So is there something wrong with my configuration? Can I make Gradle run faster?

like image 261
zduny Avatar asked Nov 12 '14 22:11

zduny


1 Answers

Create a gradle.properties file either in your project root directory or your ~/.gradle directory with the following line:

org.gradle.daemon=true

From the Gradle manual:

The Daemon is a long-lived process, so not only are we able to avoid the cost of JVM startup for every build, but we are able to cache information about project structure, files, tasks, and more in memory

Also, you can go to File > Power Save Mode if you want to turn off continuous building in Android Studio.

like image 95
Jeffrey Mixon Avatar answered Oct 11 '22 23:10

Jeffrey Mixon