From 914c659f4abdaec9fd3ae11f2f7db98ffd04059c Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Mon, 9 Nov 2026 19:05:31 -0500 Subject: [PATCH] fix(lab): size the build heap from the device's memory --- tools/agent/dd-lab-build | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/agent/dd-lab-build b/tools/agent/dd-lab-build index 01a43759bf..722ea0207f 100755 --- a/tools/agent/dd-lab-build +++ b/tools/agent/dd-lab-build @@ -42,10 +42,15 @@ if [ ! -d "$ANDROID_HOME/platforms/android-34" ]; then "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" "platforms;android-34" "build-tools;35.0.0" >/dev/null fi +# A full Kotlin compile of the app needs about 3 GB of heap; smaller devices get what they can spare. +total_mb=$(awk '/^MemTotal:/ {print int($2 / 1024)}' /proc/meminfo) +heap=$(( total_mb * 2 / 5 )); [ $heap -gt 3072 ] && heap=3072; [ $heap -lt 1536 ] && heap=1536 +heap=${DD_LAB_HEAP_MB:-$heap} + # Google publishes aapt2 for x86-64 Linux only; setup wraps it in qemu-user at ~/aapt2/aapt2. gradle=(./gradlew :app:processReleaseResources :app:mergeDexRelease --max-workers=2 -PskipRust=true -x buildVkBridgeServer -Pandroid.aapt2FromMavenOverride=$HOME/aapt2/aapt2 -Pkotlin.compiler.execution.strategy=in-process - -Dorg.gradle.jvmargs=-Xmx1800m --console=plain) + -Dorg.gradle.jvmargs=-Xmx${heap}m --console=plain) progress planning total=$("${gradle[@]}" --dry-run -q 2>/dev/null | grep -c '^:' || true) current=$(mktemp)