Jenkins agent out of memory during Gradle build causing hudson.remoting.RequestAbortedException

Viewed 311

I'm using Jenkins to build my project via Gradle (5.1). I'm able to successfully pass the first stage of my pipeline which runs a bash script with the following:

./gradlew clean build --refresh-dependencies -Dorg.gradle.jvmargs="-Xms1g -Xmx5g"

The next stage then runs:

./gradlew test -Dorg.gradle.jvmargs="-Xms1g -Xmx5g"

When running the pipeline, I see the following message:

(..., resourceRequestMemory: 12Gi, ..., resourceLimitMemory: 12Gi)

The following can be found in the Openshift documentation:

By default the Jenkins JNLP agent JVM uses 50% of the container memory limit for its heap. This value can be modified by the CONTAINER_HEAP_PERCENT environment variable

Source

I then get this error during my test stage:

Cannot contact buildslave-123wd: hudson.remoting.RequestAbortedException: java.nio.channels.ClosedChannelException

I thought I would have just under 6g of memory to play with and tried assigning it to my Gradle task. Last time this happened, we increased the amount of memory for the build agents and it solved it but I thought I'd like to get to the bottom of this.

Please note, I'm trying to use the Gradle daemon as recommended by the Gradle docs. Is this a problem? Am I allocating heap space incorrectly in my Gradle commands?

0 Answers
Related