Skip to content

chore: size the forked test JVM heap - #391

Open
abelonogov-ld wants to merge 1 commit into
mainfrom
andrey/test-jvm-heap-size
Open

chore: size the forked test JVM heap#391
abelonogov-ld wants to merge 1 commit into
mainfrom
andrey/test-jvm-heap-size

Conversation

@abelonogov-ld

@abelonogov-ld abelonogov-ld commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Why

org.gradle.jvmargs=-Xmx4608M in gradle.properties sizes the Gradle daemon, not the JVM Gradle forks to run tests. That one is left at Gradle's 512m default — no maxHeapSize is set anywhere in the build, and forkEvery is 0, so the whole module suite shares a single 512m JVM.

Measured over a full run of :launchdarkly-android-client-sdk:testReleaseUnitTest with GC logging, the suite spends most of its collector time against that ceiling:

full GCs total GC events live set after full GC
512m (current) 1048 5788 ~158m
2g (this PR) 242 2493 ~168m

The live set is modest, so this is headroom rather than a leak: a 512m ceiling over a ~160m working set with this much allocation churn just means constant full collections, and no margin when a test allocates a transient burst.

What this is not

This is not a fix for the intermittent OutOfMemoryError in FDv2DataSourceTest. That one is a spinning loop that retains memory until it exhausts whatever heap it is given — it still OOMs at 2g — and is fixed separately in #390. Deliberately kept apart so neither change is credited with the other's effect.

Test plan

  • ./gradlew test passes locally
  • Confirmed via -Xlog:gc that the numbers above are the before/after for the same task

Nothing shipped changes, so this is chore and should not cut a release.

Note: CI on this branch may hit the FDv2DataSourceTest flake until #390 merges, since this branch is on current main.


Note

Overview
Sets maxHeapSize = "2g" on all subproject Test tasks in the root build.gradle, alongside the existing EasyMock --add-opens JVM arg.

Gradle forks a separate JVM for unit tests that defaults to 512m regardless of org.gradle.jvmargs on the daemon. The full module test suite was spending most of its GC time against that ceiling even though the live set stays around ~160m; raising the forked heap reduces full GC churn during test runs.

No runtime or shipped artifact behavior changes—CI/local test execution only. This is intentionally separate from fixing FDv2DataSourceTest OOM (#390), which can still fail until that lands.

Reviewed by Cursor Bugbot for commit 6618db2. Bugbot is set up for automated code reviews on this repo. Configure here.

org.gradle.jvmargs sizes the Gradle daemon, not the JVM forked for tests,
which Gradle leaves at its 512m default. The unit test suite runs right
against that ceiling: measured over a full run of the SDK module, 1048 of
5788 GC events were full collections, against a steady live set of ~158m.
At 2g the same run does 242 full collections out of 2493.

Co-authored-by: Cursor <cursoragent@cursor.com>
@abelonogov-ld
abelonogov-ld requested a review from a team as a code owner August 17, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants