Closed boyanl closed 7 years ago
Hi @boyanl. You are perfectly right: I was actually already aware of this issue, but it is definitely time to fix it. I will do it within the next release.
Thanks for your input, Cheers, V.
this should be a non-issue when running it as a standalone fat jar, as opposed to using an application server, correct?
Yeah, shouldn't be an issue with a fat jar
There seem to be 2 cases of threads that aren't properly terminated, which causes memory leaks when the app is re-deployed, e.g. on Tomcat
In
WebSecurityConfig
:Timer
object created (for fetching metadata over HTTP), but it's not destroyed when the bean is destroyed. (thus itsTimerThread
remains alive)MultiThreadedHttpConnectionManager
has a staticReferenceQueueThread
instance, which also remains alive.Calling
.cancel()
+.purge()
on theTimer
instance, and callingMultiThreadedHttpConnectionManager.shutdownAll()
when the config is destroyed seems to solve the issue. (It's not a big deal for the sample app, but I'm guessing that someone else might also use it as a template and run into the same issue)Note: Using
MultiThreadedHttpConnectionManager.shutdownAll()
seems a bit suspect, as it shuts down all instances in the current JVM, but it's the only way to terminate theReferenceQueueThread
that I mentioned