Khi tôi cố gắng ngăn chặn tomcat8 trên Java 8, tôi nhận được một vài bộ nhớ bị rò rỉ lỗi:nhớ Tomcat8 rò rỉ
org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:142)
com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:40)
23-Jan-2015 08:18:10.202 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [pool-5-thread-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread
23-Jan-2015 08:18:10.205 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [com.util.ThreadLocalProperties$1] (value [[email protected]]) and a value of type [java.util.Properties] (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.
Các ThreadLocalProperties lớp là:
public class ThreadLocalProperties extends Properties {
private static final long serialVersionUID = -4260632266508618756L;
private final ThreadLocal<Properties> localProperties = new ThreadLocal<Properties>() {
@Override
protected Properties initialValue() {
return new Properties();
}
};
public ThreadLocalProperties(Properties properties) {
super(properties);
}
@Override
public String getProperty(String key) {
String localValue = localProperties.get().getProperty(key);
return localValue == null ? super.getProperty(key) : localValue;
}
@Override
public Object setProperty(String key, String value) {
return localProperties.get().setProperty(key, value);
}
public ThreadLocal<Properties> getThreadLocal() {
return localProperties;
}
}
và tôi bắt đầu và ngăn chặn nó như này:
@WebListener()
public class GeneralListener implements ServletContextListener {
ThreadLocalProperties threadLocalProperties = new ThreadLocalProperties(System.getProperties());
@Override
public void contextDestroyed(ServletContextEvent arg0) {
threadLocalProperties.getThreadLocal().remove();
}
@Override
public void contextInitialized(ServletContextEvent arg0) {
System.setProperties(threadLocalProperties);
}
}
Tại sao tôi nhận được tất cả bộ nhớ này bị lỗi? cũng như, khi tôi tắt máy, nó không tắt nó, tôi phải tự tay giết quá trình.
Điều gì là sai?
http://docs.oracle.com/cd/E17952_01/connector-j-relnotes-en/news-5-1-23.html – David