GC overhead limit exceeded

Hello,

I’m using the Jenkins plugin GitHub - jenkinsci/JenkinsPipelineUnit: Framework for unit testing Jenkins pipelines to execute our tests, plus we use Gradle.

As our tests grow, we now have the following error:

java.lang.OutOfMemoryError: GC overhead limit exceeded

We execute the command gradle test --test <test_folder>, which after passing a number of tests, it fails with that error.

It only happens when running over that specific folder, if we run test-by-test, there is no such error.

We already tried to increase the memory limit:

DEFAULT_JVM_OPTS='"-Xmx4g" "-Xms4g" "-XX:+HeapDumpOnOutOfMemoryError" "-XX:+PrintGCDetails" "-verbose:gc" "-XX:MaxMetaspaceSize=350m"'

But we have the same result …

So far, we have no more ideas, only testing file-by-file to avoid that error, but it’s a pure ugly workaround.

Any idea how to avoid the GC overhead limit error?