Jim*_*osa 6 grails memory-leaks hibernate 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 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.
Run Code Online (Sandbox Code Playgroud)
我实际上看到了100多个hibernate.看起来在Grails 2.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
Run Code Online (Sandbox Code Playgroud)
在 x 次保存操作后使用 hibernate withSession 和刷新会话。Hibernate会话最多缓存20000-25000个域对象,因此您需要在每x次保存操作后刷新会话。刷新会话将从休眠中删除缓存对象
| 归档时间: |
|
| 查看次数: |
1165 次 |
| 最近记录: |