 <p>If using the <a href="http://www.gradle.org/docs/current/userguide/gradle_wrapper.html">Gradle Wrapper</a> you can set <code>DEFAULT_JVM_OPTS</code> in <code>gradlew</code> like this:</p> <pre><code>DEFAULT_JVM_OPTS="-Xmx512m" </code></pre> <p>Set it in a similar fashion in <code>gradlew.bat</code> if you're on Windows:</p> <pre><code>set DEFAULT_JVM_OPTS=-Xmx512m </code></pre> <p>The Gradle Wrapper task can also be modified to include this automatically. This is how the <a href="https://github.com/gradle/gradle/blob/REL_1.8/gradle/wrapper.gradle">Gradle developers</a> have solved it:</p> <pre><code>wrapper { gradleVersion = '1.8' def jvmOpts = "-Xmx512m" inputs.property("jvmOpts", jvmOpts) doLast { def optsEnvVar = "DEFAULT_JVM_OPTS" scriptFile.write scriptFile.text.replace("$optsEnvVar=\"\"", "$optsEnvVar=\"$jvmOpts\"") batchScript.write batchScript.text.replace("set $optsEnvVar=", "set $optsEnvVar=$jvmOpts") } } </code></pre>