-
Notifications
You must be signed in to change notification settings - Fork 65
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
Lingua's use of Kotlin coroutines causes leaks in web applications #110
Comments
Hello Erik, thanks for your request. I'm not exactly sure but after doing some investigation, this seems to be a bug in Kotlin coroutines version 1.4. Version 1.5 has been released already, so updating the dependency will probably fix this issue. I will update all dependencies for the next version of Lingua but I cannot tell you at the moment when I will publish a new release. |
Thank you. I'd be willing to test a SNAPSHOT version for the next release when the bug is fixed on the main branch. |
Hi Erik, you can now clone this repository, switch to branch I close this issue here because this is not a bug in Lingua. |
Thank you. I've tested the new version and the problem is still present. Our applications are normally designed so that we can manually cancel outstanding tasks (e.g. |
I've just found out that there is a way to manually cancel coroutine execution. I will have to try this out: Perhaps it makes sense for you to ask the coroutine devs directly as they surely know more about how to handle this than I do. Please let me know as soon as you find out anything new. In the meantime, I'm going to re-open this issue again. There is obviously still something to do in my code. |
I'm not at all familiar with Kotlin coroutines but from skimming the documentation, it sounds like |
@dnb-erik-brangs I'm a bit late, I know, but I have just applied some modifications to the |
@dnb-erik-brangs I'm closing this issue now so that I can prepare the release 1.1.1. If your problem still exists despite the recent changes, please open a new GitHub issue. Thanks. |
Thank you. The problem still seems to exist. I will open a new issue and link a repository with an example application that exhibits the problem. |
That's great. I'm still willing to find a solution to your problem and I'm sure that I will find one with the help of an example application of yours. :) |
I'm using lingua 1.1.0 in a Java web application for language detection. The application is set up to load all models on the first request:
LanguageDetectorBuilder.fromAllLanguages().withPreloadedLanguageModels().build();
When I undeploy the web application from the application server, the models stay in memory. I took a heap dump using Eclipse Memory Anaylzer. The dump shows that there are still instances of the classes related to coroutines (e.g.
kotlinx.coroutines.scheduling.CoroutineScheduler$WorkerState
,kotlinx.coroutines.scheduling.WorkQueue
,kotlinx.coroutines.scheduling.CoroutineScheduler
) after undeploying the application. The coroutines still seem to reference the models.I've built a reproducer using only Servlet API that seems to show similar behaviour on Tomcat. Tomcat shows warnings like this:
Is there are way to ensure that the threads created by Lingua terminate when the application is undeployed?
The text was updated successfully, but these errors were encountered: