Hibernate Tomcat/Grails内存泄漏

Hibernate Tomcat/Grails内存泄漏,hibernate,grails,memory-leaks,tomcat7,Hibernate,Grails,Memory Leaks,Tomcat7,每次通过grails应用程序取消部署时,我都会在catalina.out日志中看到以下内容: INFO: Closing Spring root WebApplicationContext Jun 18, 2014 5:23:48 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE: The web application [/appName] appears to have started

每次通过grails应用程序取消部署时,我都会在catalina.out日志中看到以下内容:

INFO: Closing Spring root WebApplicationContext
Jun 18, 2014 5:23:48 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/appName] appears to have started a thread named [PoolCleaner[935209663:1403137427048]] but has failed to stop it. This is very likely to create a memory leak.
Jun 18, 2014 5:23:48 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/appName] created a ThreadLocal with key of type [org.codehaus.groovy.grails.orm.hibernate.support.HibernatePersistenceContextInterceptor$1] (value [org.codehaus.groovy.grails.orm.hibernate.support.HibernatePersistenceContextInterceptor$1@7b50a485]) and a value of type [java.util.HashMap] (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.
Jun 18, 2014 5:23:48 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/appName] created a ThreadLocal with key of type [org.codehaus.groovy.grails.orm.hibernate.support.HibernatePersistenceContextInterceptor$2] (value [org.codehaus.groovy.grails.orm.hibernate.support.HibernatePersistenceContextInterceptor$2@6b615702]) and a value of type [java.util.HashMap] (value [{DEFAULT=0}]) 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.
Jun 18, 2014 5:23:48 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/appName] created a ThreadLocal with key of type [org.codehaus.groovy.grails.orm.hibernate.support.HibernatePersistenceContextInterceptor$1] (value [org.codehaus.groovy.grails.orm.hibernate.support.HibernatePersistenceContextInterceptor$1@7b50a485]) and a value of type [java.util.HashMap] (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.
Jun 18, 2014 5:23:48 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/appName] created a ThreadLocal with key of type [org.codehaus.groovy.grails.orm.hibernate.support.HibernatePersistenceContextInterceptor$2] (value [org.codehaus.groovy.grails.orm.hibernate.support.HibernatePersistenceContextInterceptor$2@6b615702]) and a value of type [java.util.HashMap] (value [{DEFAULT=0}]) 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.

我实际上看到了100多只冬眠的。Grails2.0中修复了与域类相关的内存泄漏,但我使用的是2.35。如果这很可能是我的应用程序中导致这些泄漏的原因,我想知道如何排除它们。谢谢…

您的域中是否定义了HashMap类型字段。您正在bootstrap.groovy中填充该域

有人建议使用HashMap

1. Work with smaller batches of HashMap objects to process at once if possible
2. If you have a lot of duplicate strings, use String.intern() on them before putting them into the HashMap
3. Use the HashMap(int initialCapacity, float loadFactor) constructor to tune for your case

在x次保存操作后使用hibernate with session和flush会话。Hibernate会话atmost缓存20000-25000个域对象,因此您需要在每x次保存操作后刷新会话。刷新会话将从hibernate删除缓存对象

您使用Grails石英插件还是石英?请投票反对@VitaliiSamolovskikh,我们不使用石英。作为一种解决方法,我在每次部署时都会重新启动tomcat(而不是让tomcat重新部署我的grails应用程序),但我仍然在日志中看到这些条目。面对同样的问题,我没有使用quartz插件。你找到解决方案了吗?有很多人都有这些问题,但遗憾的是,到目前为止似乎没有解决方案。我相信我的一个域类中可能有一个枚举集,但我在引导过程中没有进行任何数据填充