Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OutOfMemoryError due to LineEndingsPolicy in JvmLocalCache #2067

Closed
jhonnen opened this issue Mar 18, 2024 · 2 comments · Fixed by #2072
Closed

OutOfMemoryError due to LineEndingsPolicy in JvmLocalCache #2067

jhonnen opened this issue Mar 18, 2024 · 2 comments · Fixed by #2072

Comments

@jhonnen
Copy link
Contributor

jhonnen commented Mar 18, 2024

I'm seeing sporadic OutOfMemoryErrors caused by the data retained in JvmLocalCache:
image

The large retention is caused by Gradle internal objects referenced by the line endings policy:
image

Gradle 8.6 with enabled configuration cache
Spotless Gradle 6.25.0
Windows 11

@jhonnen
Copy link
Contributor Author

jhonnen commented Mar 18, 2024

The large retention is caused by Gradle internal objects referenced by the line endings policy:

More specifically, it's the captured FormatExtension in the provider's lambda, so the following hack seems to work around that:

tasks.withType(SpotlessTask).configureEach {
    def fixedProvider = provider(LineEnding.UNIX::createPolicy)
    doFirst {
        setLineEndingsPolicy(fixedProvider)
    }
}

(setupTask is configured in afterEvaluate, so I needed to override the policy during execution time)

@jhonnen
Copy link
Contributor Author

jhonnen commented Mar 19, 2024

the captured FormatExtension seems to be a regression introduced by #1777

jhonnen added a commit to jhonnen/spotless that referenced this issue Mar 19, 2024
Fixed memory leak caused by capturing the Gradle project model
referenced by the LineEndings Provider stored in the JvmLocalCache.

Fixes diffplug#2067
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 a pull request may close this issue.

1 participant