I am using Clojure's core.async in a servlet program. I am suspecting a memory leak in the program and I recognized that the total number of alive threads does not decrease when I undeploy my application from the application server (Glassfish).
My question is: how can I clean up the unused core.async threads when I undeploy my application?
I understand that core.async manages its own thread pools:
- It uses a cached thread pool for running
(thread)
macros. The threads in the pool get cleaned up automatically after 60 seconds of inactivity according to the docs. - However, it uses a fixed thread pool for running workers. An explicit shutdown should have been called to stop this thread pool, but the thread pool implementation is not publicly visible.
What is a nice way to shut down core.async when undeploying an application?