簡體   English   中英

Tomcat / Grails內存泄漏

[英]Tomcat/Grails memory leaks

我每次使用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多個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

在x次保存操作后使用hibernate withSession和flush會話。 Hibernate會話最多緩存20000-25000域對象,因此需要在每x次保存opertaion之后刷新會話。 刷新會話將從hibernate中刪除緩存對象

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM