in integration specs for a Gradle plugin, I use the Tooling API’s GradleConnection and Gradle TestKit’s GradleRunner (which internally uses the Tooling API), and while everythings run smoothly on my machine, it fails on Travis CI with a org.gradle.launcher.daemon.client.DaemonDisappearedException: Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed) error.
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:
For the record, all of these suggestions did not help in my case. But what did help was to put a simple sudo: required in .travis.yml to enforce running outside of a container and thus relax memory constraints.