-
Notifications
You must be signed in to change notification settings - Fork 501
Description
Follow-up to #2703 — OutOfMemoryError after upgrading to Spotless 8.1.0 and JDK 21
After upgrading Spotless from 6.13.0 to 8.1.0, along with migrating our Gradle build from JDK 8 to JDK 21, we started seeing OutOfMemoryError failures when running:
./gradlew spotlessApply
Observed Behavior
Spotless fails with OutOfMemoryError during formatting. Increasing the max heap from -Xmx4G to -Xmx6G allows the task to complete, but this is unexpectedly high for our project and suggests a memory leak or excessive retention.
Investigation
To better understand the issue, I captured a heap dump and analyzed it using Eclipse Memory Analyzer (MAT). The report highlights unusually high memory usage by the Groovy formatter:
1,682 instances of com.diffplug.spotless.extra.glue.groovy.GrEclipseFormatterStepImpl$GroovyErrorListener,
loaded by com.diffplug.spotless.FeatureClassLoader @ 0x6a46c02f0 occupy 2,079,056,168 (65.92%) bytes.
This strongly suggests that the Groovy formatter step is retaining large amounts of memory, potentially due to the error listener or related parsing structures.
Expected Behavior
Spotless should not require 6GB of heap to format our codebase. Prior versions ran successfully with 4GB. Memory usage should remain stable and not scale disproportionately.
Additional Context
JDK8 + 6.13.0— works without issueJDK21 + 8.1.0— triggers OOM unless heap is increased.- Gradle version is
8.14.3
spotless configuration: https://github.com/DataDog/dd-trace-java/blob/a8d73887e079e0af17e60c037d580c2947d66dbf/build.gradle.kts#L28-L153
I can provide more info if needed.
Request
Could you please check if it is a regression in the Groovy formatter or a known issue with Spotless 8.x?
Thanks!