I\'ve been trying to compile and test a large project to use Gradle. The test run fine until they die unexpectedly. I dug around and resources said that this is due to a mem
I've also been having the same problem on CircleCI, but I didn't have any luck with any of the above. This is what I found:
-Dorg.gradle.daemon=false to my CircleCI config.yml stopped the daemon from being used, but didn't fix the problem.-Dorg.gradle.workers.max=2 to GRADLE_OPTS, or --max-workers 2 to the gradle command didn't seem to have much/any effect from what I could see. I tried --max-workers=2 just in case, because both formats seem to be floating around on Google. I connected to my CircleCI container, and in top I could still see 3-4 Java processes forking off, so not sure this is doing anything?-XX:+UnlockExperimentalVMOptions and -XX:+UseCGroupMemoryLimitForHeap in both JVM args, and in the test {} configuration inside my build as suggested by Baptiste Mesta. I don't see how this could work; I would have thought the multiple forked processes don't know what proportion of the container memory the other processes are using up? Unless I'm not understanding it correctly.In the end, I fixed it just by being nice and explicit with the memory settings, rather than using magic:
GRADLE_OPTS: -Xmx2048m -Dorg.gradle.daemon=falsetest { maxHeapSize = "512m" }Edit: You may need to go lower, depending on whether you have other processes running.