cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathaniel, Alfred" <>
Subject RE: PermGen memory leak in cocoon-jnet
Date Wed, 30 Nov 2011 13:31:48 GMT
Hi all,

URL.setURLStreamHandlerFactory is singleton call which should only be used when you own the
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 [] 
Sent: Mittwoch, 30. November 2011 14:10
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
> ->
> 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 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

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?


-- Andreas

View raw message