build: Remove global per-test JVM heap cap#5671
Open
runningcode wants to merge 3 commits into
Open
Conversation
The minHeapSize/maxHeapSize cap in the root build.gradle.kts was applied to every module's test task. Most modules do not need it, so remove it and let tests use the JVM defaults. If a specific module turns out to require a larger heap, the cap can be re-added to that module only. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
📲 Install BuildsAndroid
|
CI showed :sentry-android-core:testReleaseUnitTest fails with OutOfMemoryError (Robolectric loading the android-all jar) once the global cap is removed. Restore the 256m/2g cap for this module only, where it is actually needed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| abfcc92 | 337.38 ms | 427.39 ms | 90.00 ms |
| 4e3e79d | 369.55 ms | 418.39 ms | 48.83 ms |
| 9054d65 | 330.94 ms | 403.24 ms | 72.30 ms |
| a416a65 | 316.52 ms | 359.67 ms | 43.15 ms |
| d15471f | 315.61 ms | 360.22 ms | 44.61 ms |
| 22f4345 | 325.23 ms | 454.66 ms | 129.43 ms |
| 6b019b7 | 403.90 ms | 546.09 ms | 142.19 ms |
| d217708 | 409.83 ms | 474.72 ms | 64.89 ms |
| 52feca7 | 314.77 ms | 378.67 ms | 63.90 ms |
| f634d01 | 375.06 ms | 420.04 ms | 44.98 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| abfcc92 | 1.58 MiB | 2.13 MiB | 557.31 KiB |
| 4e3e79d | 0 B | 0 B | 0 B |
| 9054d65 | 1.58 MiB | 2.29 MiB | 723.38 KiB |
| a416a65 | 1.58 MiB | 2.12 MiB | 555.26 KiB |
| d15471f | 1.58 MiB | 2.13 MiB | 559.54 KiB |
| 22f4345 | 1.58 MiB | 2.29 MiB | 719.83 KiB |
| 6b019b7 | 0 B | 0 B | 0 B |
| d217708 | 1.58 MiB | 2.10 MiB | 532.97 KiB |
| 52feca7 | 0 B | 0 B | 0 B |
| f634d01 | 1.58 MiB | 2.10 MiB | 533.40 KiB |
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment on lines
105
to
106
| ) | ||
|
|
||
| // Cap JVM args per test | ||
| minHeapSize = "256m" | ||
| maxHeapSize = "2g" | ||
| } |
There was a problem hiding this comment.
Bug: Removing the global maxHeapSize leaves four Robolectric-using modules without an explicit heap cap, risking OutOfMemoryError in their test tasks.
Severity: MEDIUM
Suggested Fix
Apply explicit maxHeapSize settings to the testOptions.unitTests.all block for each of the affected modules: sentry-android-replay, sentry-compose, sentry-android-navigation, and sentry-android-distribution. A setting like maxHeapSize = "2g" would be consistent with the previous global configuration and the fix applied to sentry-android-core.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: build.gradle.kts#L105-L106
Potential issue: The removal of the global `maxHeapSize` setting in the root
`build.gradle.kts` leaves four modules that use Robolectric (`sentry-android-replay`,
`sentry-compose`, `sentry-android-navigation`, `sentry-android-distribution`) without an
explicit heap size configuration. These modules enable `isIncludeAndroidResources`,
which causes Robolectric to load the large `android-all` jar. Without a defined
`maxHeapSize`, their test tasks will rely on default JVM memory settings, which may be
insufficient and lead to `OutOfMemoryError` failures in the test environment,
particularly in CI or as test suites expand.
Did we get this right? 👍 / 👎 to inform future reviews.
romtsn
approved these changes
Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes the global per-test JVM heap cap from the root
build.gradle.kts:This cap was applied to every module's test task via
allprojects, but only one module actually needs it. CI confirmed that with the global cap removed, only:sentry-android-core:testReleaseUnitTestfails — withOutOfMemoryError: Java heap space, because Robolectric loads theandroid-alljar into each test JVM. Every other module passes on the JVM defaults.The cap is therefore restored to just
sentry-android-core'sbuild.gradle.kts(viatestOptions.unitTests.all { }), where it is actually required.Note: due to the fact that some tests didn't run on this PR because they were cached, we might need to add this to more tests later.