Skip to content

Commit

Permalink
android build: Allow Gradle to use more memory.
Browse files Browse the repository at this point in the history
I've been increasingly often seeing the build fail with an error
reading "Java heap space".  This seems to be because the JVM is
run with an upper bound on how much RAM it can use, and we're
hitting the limit.  The bound is already quite a bit (half a GiB)
so that using more seems unnecessary, and it's probably not a
coincidence that the build takes unreasonably long, like >30s...
but having to retry it doesn't make it go any quicker.  So,
increase the heap size permitted.

While here, correct the comment about the default value, and take
the opportunity to have Gradle stop leaving Java heap profiles
lying around on disk when it does fail this way.  I hadn't noticed
that latter config option before, but upon looking closely at this
line, it was staring me in the face.
  • Loading branch information
gnprice committed Sep 25, 2020
1 parent d11b029 commit 1e2390d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# Default value (empirically, with Gradle 6.0.1):
# -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m
# We allow more space (no MaxMetaspaceSize; bigger -Xmx),
# and don't litter heap dumps if that still proves insufficient.
org.gradle.jvmargs=-Xms256m -Xmx1024m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down

0 comments on commit 1e2390d

Please sign in to comment.