|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
PermGen space OOME on Reload Manager?After reloading the app using manager, I got the dreaded OOME error.
Could it be logging? Some web searching brought up this post: http://readlist.com/lists/tomcat.apache.org/users/3/19056.html "The PermGen space is the area where classes, methods and the like are stored. There are two possibilities to the cause of this OutOfMemory: - The best case: the application is simply loading too many classes, and they do not fit in the PermGen space. In this case, it will be enough to increase the PermGen size - The worst case: you are experiencing a problem of class (or classloader) garbage collection. Unfortunately, by your description, it seems to be your case. The problem is that, when you reload the webapp, the JVM is not being able to "garbage collect" the old web-app version. This effect is accumulative, and the more times you reload your webapp, the more space is not being freed in the PermGen space. The cause for this behaviour is that there are strong references that are not being freed when your webapp is stopped. Due to these references, the garbage collector is not able to finalize the referenced classes, or the classloader they where loaded with. This is not really a Tomcat problem, but your webapp's. There are several wide-spread programming patterns that have this effect when used in a webapp. The following are two examples that I usually find in the projects I try to "fix": - The singleton pattern creates a hard reference of the class in the class itself. This makes the class unloadable. I prefer to use the commons-discovery DiscoverSingleton class. By using this class, you can get singleton instances of the classes you need. The advantage is that you can add a ServletContextListener to your webapp, and call its static release() method within contextDestroyed, so all singleton instances are safely released. This library provides more discovery patterns that can be useful in other situations. - It is very common to find a declaration like this: private static final Log log = LogFactory.getLog(MyClass.class); >From the commons-logging API documentation: "LogFactory needs to keep a static map of LogFactory objects keyed by context classloader; when the webapp is "undeployed" this means there is still a reference to the undeployed classloader preventing the memory used by all its classes from being reclaimed." If you are using commons-logging, the LogFactory provides the "releaseAll" method, that can be used to release all the internal references, and can also be called from the ServletContextListener.contextDestroyed() method. In fact, the commons-logging documentation itself recommends to use this method in servlet containers ;-) You can also use the org.apache.commons.logging.impl.ServletContextCleaner class. There are other patterns that have the same effects, and they should all be avoided if you want your webapp to be "really" reloadable :-) Perhaps, it would be a good idea to create a section in the Tomcat WIKI to list these patterns, and their workarounds :-)..." ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ Blojsom-users mailing list Blojsom-users@... https://lists.sourceforge.net/lists/listinfo/blojsom-users |
|
|
Re: PermGen space OOME on Reload Manager?Thanks Garrett. Will take a look at adding that ServletContextCleaner since
that logging idiom below is used throughout blojsom's code. On 4/22/08 11:45 PM, "Garrett Smith" <dhtmlkitchen@...> wrote: > After reloading the app using manager, I got the dreaded OOME error. > > Could it be logging? Some web searching brought up this post: > > http://readlist.com/lists/tomcat.apache.org/users/3/19056.html > > "The PermGen space is the area where classes, methods and the like are > stored. There are two possibilities to the cause of this OutOfMemory: > > - The best case: the application is simply loading too many classes, and > they do not fit in the PermGen space. In this case, it will be enough to > increase the PermGen size > - The worst case: you are experiencing a problem of class (or > classloader) garbage collection. Unfortunately, by your description, it > seems to be your case. > > The problem is that, when you reload the webapp, the JVM is not being > able to "garbage collect" the old web-app version. This effect is > accumulative, and the more times you reload your webapp, the more space > is not being freed in the PermGen space. > > The cause for this behaviour is that there are strong references that > are not being freed when your webapp is stopped. Due to these > references, the garbage collector is not able to finalize the referenced > classes, or the classloader they where loaded with. > > This is not really a Tomcat problem, but your webapp's. There are > several wide-spread programming patterns that have this effect when used > in a webapp. The following are two examples that I usually find in the > projects I try to "fix": > > - The singleton pattern creates a hard reference of the class in the > class itself. This makes the class unloadable. I prefer to use the > commons-discovery DiscoverSingleton class. By using this class, you can > get singleton instances of the classes you need. The advantage is that > you can add a ServletContextListener to your webapp, and call its static > release() method within contextDestroyed, so all singleton instances are > safely released. This library provides more discovery patterns that can > be useful in other situations. > > - It is very common to find a declaration like this: > > private static final Log log = LogFactory.getLog(MyClass.class); > >> From the commons-logging API documentation: > > "LogFactory needs to keep a static map of LogFactory objects keyed by > context classloader; when the webapp is "undeployed" this means there is > still a reference to the undeployed classloader preventing the memory > used by all its classes from being reclaimed." > > If you are using commons-logging, the LogFactory provides the > "releaseAll" method, that can be used to release all the internal > references, and can also be called from the > ServletContextListener.contextDestroyed() method. In fact, the > commons-logging documentation itself recommends to use this method in > servlet containers ;-) You can also use the > org.apache.commons.logging.impl.ServletContextCleaner class. > > There are other patterns that have the same effects, and they should all > be avoided if you want your webapp to be "really" reloadable :-) > > Perhaps, it would be a good idea to create a section in the Tomcat WIKI > to list these patterns, and their workarounds :-)..." > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > Blojsom-users mailing list > Blojsom-users@... > https://lists.sourceforge.net/lists/listinfo/blojsom-users ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ Blojsom-users mailing list Blojsom-users@... https://lists.sourceforge.net/lists/listinfo/blojsom-users |
|
|
Re: PermGen space OOME on Reload Manager?On Tue, Apr 22, 2008 at 8:51 PM, David Czarnecki <david@...> wrote:
> Thanks Garrett. Will take a look at adding that ServletContextCleaner since > that logging idiom below is used throughout blojsom's code. > Alright. I still can't get the app to run though. I can't find the error. I reloaded, then got permgen error, then I restarted TC, but the blojsom parts of the app won't start up. This is OK: http://dhtmlkitchen.com/ape/ this is not: http://dhtmlkitchen.com/ The stack trace I get starts with a FileNotFoundException on the blojsom URI: ERROR TP-Processor2 org.apache.catalina.core.ContainerBase.[Catalina].[dhtmlkitchen.com].[/].[jsp] - Servlet.service() for servlet jsp threw exception java.io.FileNotFoundException: http://dhtmlkitchen.com/news/?page=categories at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1239) at org.apache.taglibs.standard.tag.common.core.ImportSupport.acquireReader(Unknown Source) at org.apache.taglibs.standard.tag.common.core.ImportSupport.acquireString(Unknown Source) at org.apache.taglibs.standard.tag.common.core.ImportSupport.doEndTag(Unknown Source) at org.apache.jsp.tiles.nav_jsp._jspx_meth_c_005fimport_005f0(nav_jsp.java:208) at org.apache.jsp.tiles.nav_jsp._jspService(nav_jsp.java:88) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:687) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:590) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:505) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968) at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:614) at org.apache.tiles.jsp.context.JspUtil.doInclude(JspUtil.java:93) at org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:88) at org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(JspTilesRequestContext.java:82) at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:460) at org.apache.tiles.jsp.taglib.InsertAttributeTag.render(InsertAttributeTag.java:141) at org.apache.tiles.jsp.taglib.InsertAttributeTag.render(InsertAttributeTag.java:118) at org.apache.tiles.jsp.taglib.RenderTagSupport.execute(RenderTagSupport.java:172) at org.apache.tiles.jsp.taglib.RoleSecurityTagSupport.doEndTag(RoleSecurityTagSupport.java:76) at org.apache.tiles.jsp.taglib.ContainerTagSupport.doEndTag(ContainerTagSupport.java:82) at org.apache.jsp.tiles.content_002dlayout_jsp._jspx_meth_tiles_005finsertAttribute_005f1(content_002dlayout_jsp.java:190) at org.apache.jsp.tiles.content_002dlayout_jsp._jspService(content_002dlayout_jsp.java:70) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:687) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:590) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:505) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968) at org.apache.jasper.runtime.PageContextImpl.doInclude(PageContextImpl.java:643) at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:637) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.tiles.jsp.context.JspUtil.doInclude(JspUtil.java:82) at org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:88) at org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(JspTilesRequestContext.java:82) at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:423) at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:458) at org.apache.tiles.jsp.taglib.InsertAttributeTag.render(InsertAttributeTag.java:141) at org.apache.tiles.jsp.taglib.InsertAttributeTag.render(InsertAttributeTag.java:118) at org.apache.tiles.jsp.taglib.RenderTagSupport.execute(RenderTagSupport.java:172) at org.apache.tiles.jsp.taglib.RoleSecurityTagSupport.doEndTag(RoleSecurityTagSupport.java:76) at org.apache.tiles.jsp.taglib.ContainerTagSupport.doEndTag(ContainerTagSupport.java:82) at org.apache.jsp.tiles.main_002dlayout_jsp._jspx_meth_tiles_005finsertAttribute_005f1(main_002dlayout_jsp.java:116) at org.apache.jsp.tiles.main_002dlayout_jsp._jspService(main_002dlayout_jsp.java:61) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:687) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:590) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:505) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968) at org.apache.jasper.runtime.PageContextImpl.doInclude(PageContextImpl.java:643) at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:637) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.tiles.jsp.context.JspUtil.doInclude(JspUtil.java:82) at org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:88) at org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(JspTilesRequestContext.java:82) at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:423) at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:374) at org.apache.tiles.jsp.taglib.InsertDefinitionTag.render(InsertDefinitionTag.java:65) at org.apache.tiles.jsp.taglib.RenderTagSupport.execute(RenderTagSupport.java:172) at org.apache.tiles.jsp.taglib.RoleSecurityTagSupport.doEndTag(RoleSecurityTagSupport.java:76) at org.apache.tiles.jsp.taglib.ContainerTagSupport.doEndTag(ContainerTagSupport.java:82) at org.apache.jsp.index_jsp._jspx_meth_tiles_005finsertDefinition_005f0(index_jsp.java:106) at org.apache.jsp.index_jsp._jspService(index_jsp.java:60) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.jspinsider.jspkit.gzip.GZIPFilter.doFilter(Unknown Source) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190) at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283) at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767) at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697) at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:686) at java.lang.Thread.run(Thread.java:619) > > > > On 4/22/08 11:45 PM, "Garrett Smith" <dhtmlkitchen@...> wrote: > > > After reloading the app using manager, I got the dreaded OOME error. > > > > Could it be logging? Some web searching brought up this post: > > > > http://readlist.com/lists/tomcat.apache.org/users/3/19056.html > > > > "The PermGen space is the area where classes, methods and the like are > > stored. There are two possibilities to the cause of this OutOfMemory: > > > > - The best case: the application is simply loading too many classes, and > > they do not fit in the PermGen space. In this case, it will be enough to > > increase the PermGen size > > - The worst case: you are experiencing a problem of class (or > > classloader) garbage collection. Unfortunately, by your description, it > > seems to be your case. > > > > The problem is that, when you reload the webapp, the JVM is not being > > able to "garbage collect" the old web-app version. This effect is > > accumulative, and the more times you reload your webapp, the more space > > is not being freed in the PermGen space. > > > > The cause for this behaviour is that there are strong references that > > are not being freed when your webapp is stopped. Due to these > > references, the garbage collector is not able to finalize the referenced > > classes, or the classloader they where loaded with. > > > > This is not really a Tomcat problem, but your webapp's. There are > > several wide-spread programming patterns that have this effect when used > > in a webapp. The following are two examples that I usually find in the > > projects I try to "fix": > > > > - The singleton pattern creates a hard reference of the class in the > > class itself. This makes the class unloadable. I prefer to use the > > commons-discovery DiscoverSingleton class. By using this class, you can > > get singleton instances of the classes you need. The advantage is that > > you can add a ServletContextListener to your webapp, and call its static > > release() method within contextDestroyed, so all singleton instances are > > safely released. This library provides more discovery patterns that can > > be useful in other situations. > > > > - It is very common to find a declaration like this: > > > > private static final Log log = LogFactory.getLog(MyClass.class); > > > >> From the commons-logging API documentation: > > > > "LogFactory needs to keep a static map of LogFactory objects keyed by > > context classloader; when the webapp is "undeployed" this means there is > > still a reference to the undeployed classloader preventing the memory > > used by all its classes from being reclaimed." > > > > If you are using commons-logging, the LogFactory provides the > > "releaseAll" method, that can be used to release all the internal > > references, and can also be called from the > > ServletContextListener.contextDestroyed() method. In fact, the > > commons-logging documentation itself recommends to use this method in > > servlet containers ;-) You can also use the > > org.apache.commons.logging.impl.ServletContextCleaner class. > > > > There are other patterns that have the same effects, and they should all > > be avoided if you want your webapp to be "really" reloadable :-) > > > > Perhaps, it would be a good idea to create a section in the Tomcat WIKI > > to list these patterns, and their workarounds :-)..." > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > > Don't miss this year's exciting event. There's still time to save $100. > > Use priority code J8TL2D2. > > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > > _______________________________________________ > > Blojsom-users mailing list > > Blojsom-users@... > > https://lists.sourceforge.net/lists/listinfo/blojsom-users > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > Blojsom-users mailing list > Blojsom-users@... > https://lists.sourceforge.net/lists/listinfo/blojsom-users > ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ Blojsom-users mailing list Blojsom-users@... https://lists.sourceforge.net/lists/listinfo/blojsom-users |
| Free embeddable forum powered by Nabble | Forum Help |