Утечки памяти в веб-службе Java с использованием Hibernate

Мое приложение работает нормально, но когда я останавливаю сервер, я получаю эти сообщения. Я не запускаю ни один поток вручную, но я новичок в этих технологиях и не знаю, как они работают внутри.
Я использую C3p0 для создания пула соединений, и, возможно, есть утечка, потому что соединения плохо закрываются, но я не знаю, как это сделать правильно. Но кажется, что из-за количества сообщений может быть больше проблем.
Пожалуйста, кто-нибудь может сказать мне, что все это значит и как я могу решить утечку памяти?
Пожалуйста, извините мой плохой английский. Спасибо вам всем.

...
Information: Closing Spring root WebApplicationContext
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
Severe: The web application [/Consulta] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
Severe: The web application [/Consulta] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak.
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
Severe: The web application [/Consulta] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it. This is very likely to create a memory leak.
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
Severe: The web application [/Consulta] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] but has failed to stop it. This is very likely to create a memory leak.
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
Severe: The web application [/Consulta] appears to have started a thread named [MultiThreadedHttpConnectionManager cleanup] but has failed to stop it. This is very likely to create a memory leak.
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
Severe: The web application [/Consulta] appears to have started a thread named [Timer-1] but has failed to stop it. This is very likely to create a memory leak.
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
Severe: The web application [/Consulta] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak.
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
Severe: The web application [/Consulta] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it. This is very likely to create a memory leak.
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
Severe: The web application [/Consulta] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] but has failed to stop it. This is very likely to create a memory leak.
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
Severe: The web application [/Consulta] appears to have started a thread named [Timer-2] but has failed to stop it. This is very likely to create a memory leak.
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
Severe: The web application [/Consulta] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak.
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
Severe: The web application [/Consulta] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it. This is very likely to create a memory leak.
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
Severe: The web application [/Consulta] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] but has failed to stop it. This is very likely to create a memory leak.
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
Severe: The web application [/Consulta] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@aa7d6e]) and a value of type [org.apache.myfaces.config.RuntimeConfig] (value [org.apache.myfaces.config.RuntimeConfig@110d045]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
Severe: The web application [/Consulta] created a ThreadLocal with key of type [org.apache.xml.security.algorithms.SignatureAlgorithm$3] (value [org.apache.xml.security.algorithms.SignatureAlgorithm$3@10f67f1]) and a value of type [java.util.HashMap] (value [{http://vvv.w3.org/2000/09/xmldsig#rsa-sha1=Sun RSA private CRT key, 2048 bits
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
Severe: The web application [/Consulta] created a ThreadLocal with key of type [org.apache.xml.security.algorithms.MessageDigestAlgorithm$1] (value [org.apache.xml.security.algorithms.MessageDigestAlgorithm$1@711132]) and a value of type [java.util.HashMap] (value [{http://vvv.w3.org/2000/09/xmldsig#sha1=SHA-1 Message Digest from SUN, <initialized>
}]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
Severe: The web application [/Consulta] created a ThreadLocal with key of type [org.apache.myfaces.el.convert.VariableResolverToELResolver$1] (value [org.apache.myfaces.el.convert.VariableResolverToELResolver$1@1200ec5]) and a value of type [java.util.HashSet] (value [[]]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
Severe: The web application [/Consulta] created a ThreadLocal with key of type [org.apache.xml.security.utils.UnsyncBufferedOutputStream$1] (value [org.apache.xml.security.utils.UnsyncBufferedOutputStream$1@1a9e49c]) and a value of type [byte[]] (value [[B@dfebc1]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
Severe: The web application [/Consulta] created a ThreadLocal with key of type [org.apache.xml.security.utils.UnsyncByteArrayOutputStream$1] (value [org.apache.xml.security.utils.UnsyncByteArrayOutputStream$1@eedcc3]) and a value of type [byte[]] (value [[B@1dfadaa]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
Severe: The web application [/Consulta] created a ThreadLocal with key of type [org.apache.axis.utils.XMLUtils.ThreadLocalDocumentBuilder] (value [org.apache.axis.utils.XMLUtils$ThreadLocalDocumentBuilder@b1691a]) and a value of type [com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl] (value [com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl@16b470a]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
jun 12, 2014 2:32:09 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
Severe: The web application [/Consulta] created a ThreadLocal with key of type [org.apache.xml.security.algorithms.SignatureAlgorithm$1] (value [org.apache.xml.security.algorithms.SignatureAlgorithm$1@4e554]) and a value of type [java.util.HashMap] (value [{http://vvv.w3.org/2000/09/xmldsig#rsa-sha1=org.apache.xml.security.algorithms.implementations.SignatureBaseRSA$SignatureRSASHA1@16bf810}]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository.
jun 12, 2014 2:32:10 PM org.apache.coyote.http11.Http11Protocol destroy
Information: Parando Coyote HTTP/1.1 en puerto http-8080
jun 12, 2014 2:32:10 PM org.apache.coyote.http11.Http11Protocol destroy
Information: Parando Coyote HTTP/1.1 en puerto http-8443

person agamesh    schedule 12.06.2014    source источник


Ответы (1)


Для com.mchange.v2.async.ThreadPoolAsynchronousRunner см. Как отключить пул соединений при выгрузке контекста? . Ответ относится к Spring, но если вы не используете Spring, вы можете вызвать метод close() для com.mchange.v2.c3p0.ComboPooledDataSource в ServletContextListener.

Для Timer-0, если приведенного выше решения недостаточно, см. Ошибка утечки памяти Catalina.out (особенно мой собственный ответ: https://stackoverflow.com/a/23336094/685806).

person Pino    schedule 12.06.2014
comment
Первая ссылка кажется правильной, но не дает много информации о том, как это сделать. У меня нет такого компонента для установки метода закрытия. В любом случае, как я могу вызвать метод закрытия для com.mchange.v2.c3p0.ComboPooledDataSource, если у меня есть ServletContextListener? - person agamesh; 13.06.2014
comment
Вам понадобится экземпляр этого класса ComboPooledDataSource. Поскольку вы говорите, что у вас его нет, возможно, вы используете C3p0 по-другому; поэтому вам необходимо изучить конфигурацию пула соединений и правильно разместить экземпляр пула, независимо от того, какой конкретный класс вы используете. - person Pino; 13.06.2014
comment
Наконец-то я смог закрыть пул соединений в ServletContextListener: ConnectionProvider conn = (SessionFactoryImpl)sessionFactory.getConnectionProvider(); ((C3P0ConnectionProvider)conn).close(); Спасибо! - person agamesh; 04.07.2014