Why are my Gradle builds dying with exit-code 137?

后端 未结 9 2064
醉酒成梦
醉酒成梦 2020-12-07 23:48

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

9条回答
  •  爱一瞬间的悲伤
    2020-12-08 00:48

    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:

    • Adding -Dorg.gradle.daemon=false to my CircleCI config.yml stopped the daemon from being used, but didn't fix the problem.
    • Adding -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?
    • I also tried max workers = 1 in the combinations above.
    • Tried -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:

    • Circle CI config: GRADLE_OPTS: -Xmx2048m -Dorg.gradle.daemon=false
    • Gradle build: test { maxHeapSize = "512m" }

    Edit: You may need to go lower, depending on whether you have other processes running.

提交回复
热议问题