I am using Gradle 2.5 to compile a Java project which consists of 5 modules. In order to speed things up I also use the gradle-daemon. However, During compilation there are up to 18 instances of the gradle-daemon running. After compilation finishes there are still 15 instances of the daemon left. The daemons process consumes about 600 MB of RAM. Is it normal to have that many daemons running in the background or is the gradle-daemon misconfigured?
UPDATE: My operating system is Debian Jessie. Java version is Oracle Java 8.
Following Antoniossss’ advice I got in touch with a developer. As it turns out, Gradle is in fact quite resource hungry. Even for a simple “Hello World” application the daemon might use very well up to 150 MB and maybe even more. It is also alright, that multiple daemon threads are started, as long as they run within the same JVM. There is only limited control on the user’s side to control/limit memory usage. One could set GRADLE_OPTS variable in order to pass Xmx options to the JVM, e.g., I managed to build my Android project with following settings:
$ export GRADLE_OPTS="-Xmx64m -Dorg.gradle.jvmargs='-Xmx256m -XX:MaxPermSize=64m'"
The first -Xmx option is set for the Gradle that you start in CLI, the second one (after -Dorg.gradle.jvmargs) is the -Xmx value for the Gradle-Daemon.
The less memory you allow for your JVM the higher the risk for your build to fail – obviously. So you might have to tune those settings until they suit your purposes.
Those settings can also be set in the gradle.properties file.