Tomcat8 memory leak

后端 未结 2 413
鱼传尺愫
鱼传尺愫 2020-12-13 19:55

When I try to stop tomcat8 on Java 8, I get a few memory leaks errors:

org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web applic         


        
相关标签:
2条回答
  • 2020-12-13 20:48

    There is nothing to worry about. This is a standard message tomcat outputs when it detects the application has started it's own Thread or created a ThreadLocal. If you terminate the thread on shutdown and remove the threadlocals when they are no longer needed, then there will be no problem.

    Why would I get all this memory leaks errors? as well, when I run shutdown, it doesn't shut it down, I have to manually kill the process.

    I've seen this behavior, when an application has started ScheduledExecutor (but this will happen with any other Thread/TheadPool) and didn't shut it down on contextDestroyed. So check if you are shutting down your threads on application/server stop.

    Now on your concrete problem why the server doesn't stop: JDBC drivers are registered in the JVM as singletons, and are shared with all webapps. More info here. The best solution to your problem is to move the MySQL driver in Tomcat's /lib folder. If you cannot do that you can try this but it's more like a hack than a real solution.

    0 讨论(0)
  • 2020-12-13 20:48

    I think your problem is similar to this. When you redeploy the app, apache deploys it incrementally on itself where system.gc(); do not work and after few redeployment in developing phase the permanent generated space gets full and you get memory leak error.

    Please keep restarting your server after few redeployment, so the PermGen space can be cleared with a restart.

    Or

    a you can also solve it by changing the PermGen space in server. Please visit here.

    I hope this will help you.

    0 讨论(0)
提交回复
热议问题