codecentric / spring-boot-admin

Admin UI for administration of spring boot applications
Apache License 2.0
12.38k stars 3.08k forks source link

Memoryleak in tomcat8? #545

Closed membersound closed 7 years ago

membersound commented 7 years ago

If I undeploy spring-boot-admin in a tomcat8, the following warnings for memoryleaks are displayed in the logs.

Sep 08, 2017 9:00:03 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
WARNING: The web application [adminui] appears to have started a thread named [expiringMap-0] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.misc.Unsafe.park(Native Method)
 java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
 java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 java.lang.Thread.run(Thread.java:748)

Sep 08, 2017 9:00:03 AM org.apache.catalina.loader.WebappClassLoaderBase checkThreadLocalMapForLeaks
SEVERE: The web application [adminui] created a ThreadLocal with key of type [org.springframework.cloud.netflix.zuul.filters.post.SendResponseFilter$1] (value [org.springframework.cloud.netflix.zuul.filters.post.SendResponseFilter$1@18d5c09d]) and a value of type [byte[]] (value [[B@686f361f]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Sep 08, 2017 9:00:03 AM org.apache.catalina.loader.WebappClassLoaderBase checkThreadLocalMapForLeaks
SEVERE: The web application [adminui] created a ThreadLocal with key of type [com.netflix.zuul.context.RequestContext$1] (value [com.netflix.zuul.context.RequestContext$1@6bef4112]) and a value of type [com.netflix.zuul.context.RequestContext] (value [{}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

Where might this come from? Maybe sba is missing some kind of shutdown hook to close the maps?

spring.boot.admin.routes.endpoints=env,metrics,trace,info,configprops,logfile,loggers,refresh,auditevents

sba-1.5.4 tomcat8.0.32

joshiste commented 7 years ago

One ThreadLocal warning is an error in spring cloud netflix and I've submitted an issue: https://github.com/spring-cloud/spring-cloud-netflix/issues/2283

The other warning is a bug in our OptionsDispatchingZuulController. It looks like we can get rid of it, but I need to do some investigation on that...

And currently I've no idea where the expiringMap-0 thread is spawned....