Travis CI: org.gradle.launcher.daemon.client.DaemonDisappearedException: Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)

Actually, the problem seems to be that on Travis the initial jvm heap size is nearly 1GB. Since Gradle forks quite a few JVMs by default (Compiler Daemons, Test Executors, TestKit Daemons), the memory pressure becomes too high and Travis begins to kill processes.

I solved it by controlling the number of forked JVMs (5) and reducing the initial heap size:

// build.gradle
if (System.env.TRAVIS == 'true') {
  allprojects {
    tasks.withType(GroovyCompile) {
      groovyOptions.fork = false
    tasks.withType(Test) {
      // containers (currently) have 2 dedicated cores and 4GB of memory
      maxParallelForks = 2
      minHeapSize = '128m'

// .travis.yml
    - GRADLE_OPTS="-Xms128m"
1 Like