From 8b7af243b374984bda5504e4d7c8a2e7495b2042 Mon Sep 17 00:00:00 2001 From: Moe Hamade <69801237+moehamade@users.noreply.github.com> Date: Wed, 26 Aug 2026 00:05:30 +0300 Subject: [PATCH] build: raise Gradle metaspace to 1g KSP and the Dagger/Hilt annotation processors load enough additional classes into the daemon that a combined testDebugUnitTest + lintDebug run exhausts the previous 512m ceiling. The failure is worth describing because it does not name its cause: it surfaces as an OutOfMemoryError inside ClassLoader.defineClass in whichever task happens to be loading classes at the time, including lint on an unrelated module. When it lands during a --write-verification-metadata run it can also truncate gradle/verification-metadata.xml to zero bytes, which then fails the next build with "Unable to read dependency verification metadata: Premature end of file". JVM arguments are not build inputs, so this does not affect reproducibility. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01NaZivRfLu7FdKjzVwwRjcc --- gradle.properties | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index e3461bd0..5ff2de48 100644 --- a/gradle.properties +++ b/gradle.properties @@ -27,8 +27,14 @@ kotlin.code.style=official # signed by an unexpected publisher. BITCHAT_GITHUB_RELEASE_CERT_SHA256=3b03fa66a5451321100792f5b55a7b4966d5c8dc10c6daa40aa95ea489531bca -# JVM heap size configuration to prevent OutOfMemoryError -org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError +# JVM heap size configuration to prevent OutOfMemoryError. +# Metaspace is 1g rather than 512m: KSP and the Hilt/Dagger annotation +# processors load a large amount of extra classes into the daemon, and at 512m +# a combined test + lint + KSP invocation across the modules exhausts it. The +# failure surfaces as ClassLoader.defineClass OutOfMemoryError in unrelated +# tasks, and can truncate gradle/verification-metadata.xml if it lands during +# a --write-verification-metadata run. +org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g -XX:+HeapDumpOnOutOfMemoryError # Enabled parallel sync for Gradle 9.4+ org.gradle.tooling.parallel=true