In gradle 5 they vastly reduced the default memory requirements.
The command line client now starts with 64MB of heap instead of 1GB. This may affect builds running directly inside the client VM using --no-daemon mode. We discourage the use of --no-daemon, but if you must use it, you can increase the available memory using the GRADLE_OPTS environment variable.
The Gradle daemon now starts with 512MB of heap instead of 1GB. Large projects may have to increase this setting using the org.gradle.jvmargs property.
All workers, including compilers and test executors, now start with 512MB of heap. The previous default was 1/4th of physical memory. Large projects may have to increase this setting on the relevant tasks, e.g. JavaCompile or Test.
Increase Client Memory
GRADLE_OPTS=-Xmx1g ./gradlew build
Increase Daemon Memory
./gradlew -D org.gradle.jvmargs=-Xmx1g
Update:
For additional clarification, gradle uses a client VM, a daemon VM, worker VMs (when run in parallel), and additional VMs for certain tasks.
The client VM can be customized using the GRADLE_OPTS environment variable.
The daemon VM can be customized using the org.gradle.jvmargs property.
The worker VMs are forked from the daemon VM so will use the same settings.
The per task VMs can be customized through the task. For example
tasks.withType(JavaCompile) {
options.compilerArgs += ['-Xdoclint:none', '-Xlint:none', '-nowarn']
}
According to the gradle documentation on Client VM usage:
The client VM only handles command line input/output, so it is rare that one would need to change its VM options.