ThreadLocal en aplicacion web
Hola estaba leyendo hace un tiempo sobre la perdida de memoria que sucede cuando se usan ThreadLocal en aplicaciones web, bien yo estoy desarrollando una y usamos para pruebas en servidor tomcat lo que sucede es que cuando carga el la aplicacion manda este mensaje:
Grave: The web application [/Sistema] created a ThreadLocal with key of type [javax.faces.context.FacesContext$1] (value [javax.faces.context.FacesContext$1@1cb35da]) and a value of type [com.sun.faces.config.InitFacesContext] (value [com.sun.faces.config.InitFacesContext@3c855d]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
la aplicacion corre y hace todo lo que tiene que hacer el problema viene cuando se guarda un registro y se imprime un reporte o tiket la aplicacion se para porque el servidor tomcat se cayo:
y muestra este mensaje:
Grave: The web application [/Sistema] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.
ene 24, 2012 11:54:42 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
Grave: The web application [/Sistema] 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.
ene 24, 2012 11:54:42 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
Grave: The web application [/Sistema] 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.
ene 24, 2012 11:54:42 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
Grave: The web application [/Sistema] 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.
ene 24, 2012 11:54:42 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
Grave: The web application [/Sistema] appears to have started a thread named [AWT-Shutdown] but has failed to stop it. This is very likely to create a memory leak.
ene 24, 2012 11:54:42 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
Grave: The web application [/Sistema] appears to have started a thread named [AWT-EventQueue-0] but has failed to stop it. This is very likely to create a memory leak.
ene 24, 2012 11:54:42 AM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
Grave: The web application [/Sistema] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@15f0cd3]) and a value of type [org.hibernate.transaction.JDBCTransaction] (value [org.hibernate.transaction.JDBCTransaction@142f573]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
ene 24, 2012 11:54:42 AM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
Grave: The web application [/Sistema] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@1007177]) and a value of type [net.sf.jasperreports.repo.SimpleRepositoryContext] (value [net.sf.jasperreports.repo.SimpleRepositoryContext@195f05]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
ene 24, 2012 11:54:42 AM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
Grave: The web application [/Sistema] created a ThreadLocal with key of type [net.sf.jasperreports.engine.util.JRFontUtil$1] (value [net.sf.jasperreports.engine.util.JRFontUtil$1@2cfe1f]) 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.
ene 24, 2012 11:54:42 AM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
Grave: The web application [/Sistema] created a ThreadLocal with key of type [net.sf.jasperreports.engine.util.JRFontUtil$1] (value [net.sf.jasperreports.engine.util.JRFontUtil$1@2cfe1f]) 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.
ene 24, 2012 11:54:42 AM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
Grave: The web application [/Sistema] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@1dfb8cd]) and a value of type [net.sf.jasperreports.engine.export.legacy.BorderOffset$1] (value [net.sf.jasperreports.engine.export.legacy.BorderOffset$1@ddc5c0]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
ene 24, 2012 11:54:42 AM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
Grave: The web application [/Sistema] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@1007177]) and a value of type [net.sf.jasperreports.repo.SimpleRepositoryContext] (value [net.sf.jasperreports.repo.SimpleRepositoryContext@1e1c2be]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
ene 24, 2012 11:54:42 AM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
yo se que hay una perdida de memoria por eso el unico thead local que implemento yo le hago un remove noce si estara bien o deba quitarlo espero sus sugerencias.
El sistema es en jsf hibernate
- Inicie sesión o regístrese para enviar comentarios
Usa JMS
Los Thread no son recomendables en aplicaciones WEB, mejor usa Java Message Service para que sea el servidor de aplicaciones el que se encargue.
Gracias
Gracias por tu respuesta ire a leer y vere como lo implemento
Como casi siempre, la
Como casi siempre, la recomendación depende de cuales sean tus necesidades.
Dale un vistazo a Quartz:
Es muy utilizado en ambientes web.
Saludos.
RuGI