Continuous mode eating too much memory

It might be expected behaviour that the memory usage is what you are experiencing. The default maximum heap size for the Gradle daemon client and daemon is 1024 MB. There are also separate Java processes for the Compiler daemons and test runners.

You could adjust the JVM options to optimize for low memory usage by lowering the daemon client JVM’s max heap size to something like 200MB.

export GRADLE_OPTS="-Xmx200m -Dorg.gradle.jvmargs='-Xmx1024m -XX:MaxPermSize=256m'"
You can omit the MaxPermSize setting on Java 8+.

The memory of compiler daemons can be configured with something like this:

    allprojects {
        tasks.withType(JavaCompile) {
            options.forkOptions.memoryMaximumSize = '512m'
        }
    
        tasks.withType(GroovyCompile) {
            groovyOptions.forkOptions.memoryMaximumSize = '512m'
        }
    }

IIRC, the Java compiler doesn’t fork by default.