GradleWorker process using too much memory

Hi,

I have a project that use 3GB memory for compiling. When I run tests then gradle first start a GradleWorkerMain that compiles. That java process will consume 3GB memory while compiling. The gradle will start a new process for tests but the original GradleWorkerMain will continue to reserve 3GB of memory (since the JVM is reluctant to release memory). After a while Linux will start killing processes due to high memory consumption.

I have a workaround. If I run ./gradlew test

then it will run out of memory.

But if I instead run ./gradlew testClasses ./gradlew test the it will not run out of memory.

Is there a better way of doing this? Is there a way to configure gradle to shutdown gradleworkers when done compiling?

I am using 1.10.

Do you compile a huge set of classes in one go? Do you use in-process or forked compilation? Have you tried to configure memory settings for (forked) compilation tasks?