Tomcat / Grails memory leak

In my catalina.out log, I see the following: I refuse the grails application:

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. 

In fact, I see more than 100 sleeping. It looks like there was a memory leak related to domain classes, which was fixed in Grails 2.0, but I'm using 2.35. If this is most likely something in my application that causes these leaks, I would like to know how to fix them. Thanks...

+6
source share
1 answer

Your domain has a HashMap type field defined. And you fill this domain in your bootstrap.groovy?

There is some suggestion using 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 

Use hibernate withSession and a cleanup session after x number of save operations. Hibernate session atmost cache 20000-25000 domain object, so you need to clear the session after every x save operation. flushing session will remove the cache object from sleep mode

+1
source

Source: https://habr.com/ru/post/971068/


All Articles