My application runs as a plugin to another app which can get reinstalled multiple times, each time reloading all its classes, including kotlin ones (it uses OSGI). Right now, coroutine threads from thread pool are orphaned after reinstallation, causing memory leak.
Is there any way to shutdown underlying threads from coroutine dispatchers? (I’m using default one and IO)
One solution I see, is to provide my custom thread pool, but wouldn’t that lack some optimizations, like no need for thread switching when switching between default and IO dispatchers?