-
Notifications
You must be signed in to change notification settings - Fork 160
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
Memory leak in ktlintFormat task #507
Comments
Yes, for some unknown reason (Kotlin update) Ktlint 0.41.0 uses more memory then before... |
@BraisGabin do you see similar behaviour with KtLint |
Yes, same behaviour. I'm using this to reproduce it: for run in {1..20}; do ./gradlew ktlintFormat --rerun-tasks; done And after some runs I get this type of outputs:
|
I'm also still seeing this |
I know it doesn't solve the issue, but you can still increase the heap size as described in the README since the default heap is 256 mb.
|
I believe there's a memory leak in the underlying ktlint library and then the gradle daemon's memory is eventually exhausted. |
After updating to Gradle 7 I see this issue more often, now I can reproduc it in CI too (randomly). I assume that this increase is related with #457 because now more tasks are runned. Is there something where I could help? I'm a bit lost here. |
@BraisGabin probably sharing heap dump may help. I still suspect problem in KtLint -> Internal Kotlin version |
@Tapchicoma I cannot share the whole heap dump, but did you find anything based off of my screenshot? |
I had been scouting for possible commits in ktlint between 0.40.0 and 0.41.0 that may have been the causes. Possibly a closure approach can make sure the factory is always released (with a withPsiFileFactory { psiFileFactory ->
// some linting code
} The other possibility is that the reference counting approach isn't accounting for all situations? |
I have run into the same issue as well. Even changing the following to
|
Just an FYI for anyone seeing this that this may have been fixed in ktlint 0.43.0. See pinterest/ktlint#1216 and the linked kotlinter-gradle issue. |
@breispeloton Thanks! I've updated our plugin and hopefully it will be resolved. |
I can't reproduce this issue anymore. @gabrielittner if you can confirm it too I can close the issue. @breispeloton thanks for the heads up! |
Can also confirm: Explicitly setting the ktlint-version to 0.43.0 seems to have solved the problem for me as well.
|
Okay, so I've been running with version 0.43.0 since this was last updated, and I just now started seeing this issue again.
|
Can you open a new issue? Also, can you provide additional information? For example, a build scan link would be helpful, version of the plugin you are using, Gradle version, Ktlint version, ect... |
Probably related with #447
I'm running
git rebase -i develop --exec "./gradlew ktlintFormat"
on a branch with 40 commits and I'm getting this error on my local machine (macOS):It seems like a leak to me. The first 5 coomits ok, then the next failed. I reran the task manually on that commit and it worked. But then the 8th commit failed. and the pattern continued until the commit 15th. I can't run the task any more. It fails every single time with the error I pasted above. As soon as I killed the daemon
./gradlew --stop
it worked.I'm using v10.1.0
The text was updated successfully, but these errors were encountered: