Re: PermGen memory leak in cocoon-jnet
Am 29.11.11 02:55, schrieb Andreas Hartmann: Hi everyone, when undeploying a C3 app, I'm experiencing a PermGen memory leak due to cocoon-jnet. You find more general info on the subject at [1]. This is the reference chain: class java.net.URL - org.apache.cocoon.jnet.URLStreamHandlerFactoryInstaller$ParentableURLStreamHandlerFactory - org.apache.cocoon.jnet.URLStreamHandlerFactoryInstaller$ParentableURLStreamHandlerFactory - org.apache.catalina.loader.WebappClassLoader The problem is this line of code in URLStreamHandlerFactoryInstaller; commenting it out resolves the memory leak: URL.setURLStreamHandlerFactory(new ParentableURLStreamHandlerFactory(factory, null)); Here the static reference from java.net.URL to a Cocoon class is set. Does anyone know if and how the reference can be removed, or if we can achieve the same behaviour without registering the factory with java.net.URL? The following patch avoids the memory leak, but I have the feeling that it has functional drawbacks, otherwise the code would already look like this :) Does anybody know how I can test if the class still fulfils its purpose? Maybe it's possible to provide a unit test? TIA! Index: src/main/java/org/apache/cocoon/jnet/URLStreamHandlerFactoryInstaller.java === --- src/main/java/org/apache/cocoon/jnet/URLStreamHandlerFactoryInstaller.java (revision 1208388) +++ src/main/java/org/apache/cocoon/jnet/URLStreamHandlerFactoryInstaller.java (working copy) @@ -28,13 +28,8 @@ public class URLStreamHandlerFactoryInstaller { public static void setURLStreamHandlerFactory(URLStreamHandlerFactory factory) throws Exception { -try { -// if we can set the factory, its the first! -URL.setURLStreamHandlerFactory(new ParentableURLStreamHandlerFactory(factory, null)); -} catch (Error err) { -ParentableURLStreamHandlerFactory currentFactory = getCurrentFactory(); -setCurrentFactory(new ParentableURLStreamHandlerFactory(factory, currentFactory)); -} +ParentableURLStreamHandlerFactory currentFactory = getCurrentFactory(); +setCurrentFactory(new ParentableURLStreamHandlerFactory(factory, currentFactory)); } -- Andreas -- Andreas Hartmann, CTO BeCompany GmbH http://www.becompany.ch Tel.: +41 (0) 43 818 57 01
RE: PermGen memory leak in cocoon-jnet
Hi all, URL.setURLStreamHandlerFactory is singleton call which should only be used when you own the JVM. Calling it from C3 which is expected to play nicely with other servlets in the same container, it is a no-no. Jnet should be changed, for example by providing a createURL(String spec) factory method which calls the URL(protocol,host,port,file,handler) with the handler matching the custom protocol. Cheers, Alfred. -Original Message- From: Andreas Hartmann [mailto:andr...@apache.org] Sent: Mittwoch, 30. November 2011 14:10 To: dev@cocoon.apache.org Subject: Re: PermGen memory leak in cocoon-jnet Am 29.11.11 02:55, schrieb Andreas Hartmann: Hi everyone, when undeploying a C3 app, I'm experiencing a PermGen memory leak due to cocoon-jnet. You find more general info on the subject at [1]. This is the reference chain: class java.net.URL - org.apache.cocoon.jnet.URLStreamHandlerFactoryInstaller$ParentableURLStreamHandlerFactory - org.apache.cocoon.jnet.URLStreamHandlerFactoryInstaller$ParentableURLStreamHandlerFactory - org.apache.catalina.loader.WebappClassLoader The problem is this line of code in URLStreamHandlerFactoryInstaller; commenting it out resolves the memory leak: URL.setURLStreamHandlerFactory(new ParentableURLStreamHandlerFactory(factory, null)); Here the static reference from java.net.URL to a Cocoon class is set. Does anyone know if and how the reference can be removed, or if we can achieve the same behaviour without registering the factory with java.net.URL? The following patch avoids the memory leak, but I have the feeling that it has functional drawbacks, otherwise the code would already look like this :) Does anybody know how I can test if the class still fulfils its purpose? Maybe it's possible to provide a unit test? TIA! -- Andreas N��{^����zf��+�קu�h�\���ay�'~'^�ؚ����az�u�ǝ!ޞ�m�觵��y��r*bz{i���zz-��jw]zW�z�b�隊X���bjץ�8Z�L�
Re: PermGen memory leak in cocoon-jnet
On 29/11/2011 02:55, Andreas Hartmann wrote: Hi everyone, when undeploying a C3 app, I'm experiencing a PermGen memory leak due to cocoon-jnet. You find more general info on the subject at [1]. This is the reference chain: class java.net.URL - org.apache.cocoon.jnet.URLStreamHandlerFactoryInstaller$ParentableURLStreamHandlerFactory - org.apache.cocoon.jnet.URLStreamHandlerFactoryInstaller$ParentableURLStreamHandlerFactory - org.apache.catalina.loader.WebappClassLoader The problem is this line of code in URLStreamHandlerFactoryInstaller; commenting it out resolves the memory leak: URL.setURLStreamHandlerFactory(new ParentableURLStreamHandlerFactory(factory, null)); Here the static reference from java.net.URL to a Cocoon class is set. Does anyone know if and how the reference can be removed, or if we can achieve the same behaviour without registering the factory with java.net.URL? TIA for any hints! Hi Andreas, first of all, I don't know how to fix the issue you are pointing out :-) I just want to outline that cocoon-jnet [2] is just another example of Cocoon subproject that would need some maintenance, as currently discussing in thread [3]: are you interested in joining such conversation? Regards. [1] http://blogs.oracle.com/fkieviet/entry/how_to_fix_the_dreaded [2] https://svn.apache.org/repos/asf/cocoon/trunk/subprojects/cocoon-jnet/ [3] https://mail-archives.apache.org/mod_mbox/cocoon-dev/20.mbox/%3c4ed0fb57.3050...@apache.org%3E -- Francesco Chicchiriccò Apache Cocoon Committer and PMC Member http://people.apache.org/~ilgrosso/
PermGen memory leak in cocoon-jnet
Hi everyone, when undeploying a C3 app, I'm experiencing a PermGen memory leak due to cocoon-jnet. You find more general info on the subject at [1]. This is the reference chain: class java.net.URL - org.apache.cocoon.jnet.URLStreamHandlerFactoryInstaller$ParentableURLStreamHandlerFactory - org.apache.cocoon.jnet.URLStreamHandlerFactoryInstaller$ParentableURLStreamHandlerFactory - org.apache.catalina.loader.WebappClassLoader The problem is this line of code in URLStreamHandlerFactoryInstaller; commenting it out resolves the memory leak: URL.setURLStreamHandlerFactory(new ParentableURLStreamHandlerFactory(factory, null)); Here the static reference from java.net.URL to a Cocoon class is set. Does anyone know if and how the reference can be removed, or if we can achieve the same behaviour without registering the factory with java.net.URL? TIA for any hints! [1] http://blogs.oracle.com/fkieviet/entry/how_to_fix_the_dreaded -- Andreas -- Andreas Hartmann, CTO BeCompany GmbH http://www.becompany.ch Tel.: +41 (0) 43 818 57 01