gradle Gradle Performance Tuning JVM Memory Usage Parameters for Gradle


You can set or increase memory usage limits (or other JVM arguments) used for Gradle builds and the Gradle Daemon by editing $GRADLE_USER_HOME/.gradle/ (~/.gradle/ by default), and setting org.gradle.jvmargs.

To configure these limits only for a specific project, edit that project's file instead.

The default memory usage settings for Gradle builds and the Gradle Daemon are:

org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=256m

This allows a general maximum memory allocation (heap size) of 1GB, and a maximum memory allocation for permanent "internal" objects of 256MB. When these sizes are reached, Garbage Collection occurs, which can decrease performance significantly.

Assuming you have the memory to spare, you could easily double these like so:

org.gradle.jvmargs=-Xmx2024m -XX:MaxPermSize=512m

Note that you'll stop seeing benefit from increasing XX:MaxPermSize sooner than when Xmx increases stop becoming beneficial.