Skip to content

Commit

Permalink
android build: Allow Gradle to use another 25% more memory
Browse files Browse the repository at this point in the history
After the upcoming RN v0.68 upgrade, I start seeing failures in
`tools/test native` with the error message "Java heap space".
So, I guess we need to let Gradle's JVM use still more RAM.

Previously in 1e2390d in 2020-09 we increased this limit from
half a GiB to a whole GiB.  Make it 1.25 GiB; that seems to be
enough for now.

Compare facebook/react-native@a2a703247, which happened on the
way to RN v0.68.  That one had the explanation

  > Updates maximum heap size for the gradle build to account for
  > building RN from source when new architecture is enabled.

which doesn't apply as we aren't yet adopting RN's New Architecture.
But perhaps if we did, we'd need to increase the heap size even more:
that commit takes it to 2 GiB.

Even on my desktop with its 32 GiB of RAM, that kind of memory
consumption can get to be a strain together with everything else:
Android Studio; an Android emulator; a browser; VS Code, which is
basically another browser; Flow; and so on.  More RAM used by
programs directly means less for the system's disk cache, which
means everything runs slower as the machine keeps re-reading stuff
from disk, stuff that it just read a little while ago but didn't
have the spare memory to keep around.  Hence trying to keep this
number down as long as we can.
  • Loading branch information
gnprice committed Dec 13, 2022
1 parent a5ee49b commit 3677788
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# -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
org.gradle.jvmargs=-Xms256m -Xmx1280m

# 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 3677788

Please sign in to comment.