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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NaZivRfLu7FdKjzVwwRjcc
This commit is contained in:
Moe Hamade 2026-08-26 00:05:30 +03:00
parent e6db3ec7e4
commit 8b7af243b3

View File

@ -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