-
Notifications
You must be signed in to change notification settings - Fork 274
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
KSP memory leak in Android build #2073
KSP memory leak in Android build #2073
Comments
I may have found the root cause of this issue while investigating a reported memory leak in the Kotlin daemon: https://youtrack.jetbrains.com/issue/KT-72169. I believe the custom implementation of ThreadLocal in KSObjectCacheManager is leaking the class loader due to never being removed from the thread. Adding I also recommend that all other ThreadLocals used within KSP are removed during cleanup as well. I don't think they'll leak the class loader, but they will at least leak a class instance. |
That looks like exactly what I was finding in my heap dumps investigating this issue. Thanks @bnorm ! |
@ting-yuan I've been getting hit by this a lot. Any chance a fix can get into a coming release? |
Hello! While investigating OOMs in our build we detected that heap space and metaspace is not being reclaimed after the build finishes, and mainly meta space keeps growing with each incremental build we run on both Gradle and Kotlin daemons.
It also seems that when ksp tasks run, the heap and meta space start to grow considerably
Is it possible that there is a memory leak somewhere in KSP?
Here's some info while running the heap dump through Eclipse MAT and Visual VM
I can share the heap dump if that's helpful. Let me know if you need anything else from my side to investigate this
The text was updated successfully, but these errors were encountered: