Hi,
Recently in kotlin 2.3.20 we've discovered a preformance issue (https://youtrack.jetbrains.com/projects/KT/issues/KT-84152) that can affect KSP as well.
TL;DR: kotlin frontend unexpectedly spawn coroutines Default Dispatcher thread and doesn't stop it. When using isolated classloaders it will make them unclean-able by GC. So manual Dispatchers.shutdown is required.
This particular code:
|
var isolatedClassLoaderCache = mutableMapOf<String, URLClassLoader>() |
May cause OOMs in large builds that actively use KSP.
You may need to improve classloader cache by adding some timeout so it can call "Dispatchers.shutdown", or you can fix this issue by creating a parent classloader with kotlinx coroutines and share it with all KSP tasks.