Memory leaks in MyFaces

守給你的承諾、 提交于 2019-12-23 18:31:04

问题


EDIT: The solution that you can find in comments below assumes changing JSF implemenetation from MyFaces to Sun's Mojarra.

Hi,

I have got really annoying problem with MyFaces 2.0.0 (To be more precisely I checked it out also on 2.0.1 and 2.0.2 and problem remains).

I'm writing now application under MyFaces. Briefly speaking in my application i use frameworks: Spring, Hibernate, JSF (MyFaces implementation) My application container is Tomcat (6.0.29 version) I use maven to build and deploy (version 3.0).

The problem is when I try to redeploy application via maven (mvn tomcat:redeploy) it tries first to undeploy application and the deploy it again. But undeploying never suceed. I've got information:

SEVERE: The web application [/adam] created a ThreadLocal with key of type 
[java.lang.ThreadLocal] (value [java.lang.ThreadLocal@4b0a4d7c]) and a value of type
[org.apache.myfaces.config.RuntimeConfig] (value  org.apache.myfaces.config.RuntimeConfig@11652e61])
but failed to remove it when the web application was stopped.
This is very likely to create a memory leak.

Due to this error tomcat cannot undeploy application:

INFO: Undeploying context [/adam]
2010-12-02 11:47:46 org.apache.catalina.startup.ExpandWar deleteDir
SEVERE: [D:\Program Files\apache-tomcat-6.0.29\webapps\adam\WEB-INF\lib] could not be completely deleted. The presence of the remaining files may cause problems
2010-12-02 11:47:46 org.apache.catalina.startup.ExpandWar deleteDir
SEVERE: [D:\Program Files\apache-tomcat-6.0.29\webapps\adam\WEB-INF] could not be completely deleted. The presence of the remaining files may cause problems
2010-12-02 11:47:46 org.apache.catalina.startup.ExpandWar deleteDir
SEVERE: [D:\Program Files\apache-tomcat-6.0.29\webapps\adam] could not be completely deleted. The presence of the remaining files may cause problems
2010-12-02 11:47:46 org.apache.catalina.startup.ExpandWar delete
SEVERE: [D:\Program Files\apache-tomcat-6.0.29\webapps\adam] could not be completely deleted. The presence of the remaining files may cause problems
2010-12-02 11:47:49 org.apache.catalina.startup.HostConfig deployDirectory

All of my libraries in WEB-INF\lib and my file where i keep logs from Log4J cannot be deleted.

There is also connected memory leak from library that provides ELFactoryImpl:

SEVERE: The web application [/adam] created a ThreadLocal with key of type [null]
(value [org.apache.myfaces.el.convert.VariableResolverToELResolver$1@693985fc])
and a value of type [java.util.HashSet] (value [[]]) but failed to remove it
when the web application was stopped.
This is very likely to create a memory leak.

How to get rid of this memory leaks ?

I have been looking for answer really long I cannot find any solution. I found this issue on myface's jira: https://issues.apache.org/jira/browse/MYFACES-2942 But I don't know what to think about it. Should I wait for version 2.0.3 ?

I think that memory leak from EL is connected to first one.

Please, help me ! ;) I can provide more details if needed.


回答1:


The problem has already been reported and will be fixed. As of now you have 3 options:

  1. Live with the warning message and wait until MyFaces guys release the fix.

  2. Apply the proposed patch in your current MyFaces implementation.

  3. Replace MyFaces by Mojarra (the reference implementation) which doesn't expose this problem.



来源:https://stackoverflow.com/questions/4334510/memory-leaks-in-myfaces

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!