问题
I am using Quartz job to do some backend processing, which result into bulk upload to database. I am explicitly clearing up the session as given below.
class MyService {
def sessionFactory
static transactional = false
def runJob() {
def collectionOfDomain = []
for {
collectionOfDomain.add(someData)
if(collectionOfDomain.size() == 200) {
SomeDomain.saveAll(collectionOfDomain)
sessionFactory.currentSession.flush()
sessionFactory.currentSession.clear()
collectionOfDomain.clear()
}
}
}
}
My process runs fine for some instances, and after few successful executions, I see following errors in the logs. I see the same error when I shutdown the server. I am using Grails 2.3.6 and Postgres and Hibernate 3.6.x
Thanks a lot for your help!!!
Jul 24, 2014 7:27:46 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [] 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@45331d5e]) 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.
Jul 24, 2014 7:27:46 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [] 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@1ecd29d0]) 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.
Jul 24, 2014 7:27:46 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [] 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@45331d5e]) 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.
Jul 24, 2014 7:27:46 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [] 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@1ecd29d0]) 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.
Jul 24, 2014 7:27:46 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [] 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@45331d5e]) 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.
Jul 24, 2014 7:27:46 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [] 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@1ecd29d0]) 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.
Jul 24, 2014 7:27:46 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [] 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@45331d5e]) 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.
Jul 24, 2014 7:27:46 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [] 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@1ecd29d0]) 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.
Jul 24, 2014 7:27:46 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [] 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@45331d5e]) 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.
Jul 24, 2014 7:27:46 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [] 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@1ecd29d0]) 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.
Jul 24, 2014 7:27:46 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [] 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@45331d5e]) 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.
Jul 24, 2014 7:27:46 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [] 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@1ecd29d0]) 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.
Jul 24, 2014 7:27:46 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [] 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@45331d5e]) 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.
Jul 24, 2014 7:27:46 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [] 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@1ecd29d0]) 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.
Jul 24, 2014 7:27:46 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [] 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@45331d5e]) 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.
Jul 24, 2014 7:27:46 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [] 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@1ecd29d0]) and a value of type [java.util.HashMap] (value [{DEFAULT=0}
来源:https://stackoverflow.com/questions/24947306/grails-memory-leakage-for-bulk-upload-hibernatepersistencecontextinterceptor