Chuck,
I know that your knowledge of jvm internals is far superior to mine
and maybe I'm just missing a point, but for me the difference is
obvious.

The Factory only has a static field. That means that Impl class and
impl object can't be released as long as the factory isn't released.
But as long as the factory itself isn't linked by an attribute which
is inside the impl, the factory class can be released. As soon as the
factory class is released nothing references the singleton impl object
and it can be released. If its released so is it class, and its
classloader which is or helds the webapp classloader.

Now without the factory, we have a situation where the
classloader can't be released since its referenced by the class
object, which is referenced by the impl object, which is again
referenced by the class object (as the static variable).

With suns jdk 1.5 i actually experienced oome  on redeploy with code
without any issues mentioned by your article. After we removed
singleton dependency it went away.

regards
Leon


On 2/16/07, Caldarale, Charles R <[EMAIL PROTECTED]> wrote:
> From: Leon Rosenberg [mailto:[EMAIL PROTECTED]
> Subject: Re: PermGen space [ot]
>
>  public class ASingletonFactory{
>     private static ASingletonImpl instance = new ASingletonImpl();
>     public static  AsingletonImpl getInstance(){
>        return instance;
>    }
> }
>
>  public class ASingletonImpl{
>     ASingletonImpl(){
>     }
>     ///real code here
>  }

That does not alter the situation in the least, if any other class
contains a reference to the factory, since the factory contains a
reference to the singleton class.  If the factory is accessed via
reflection rather than direct reference, then both the factory and
singleton can be collected when not in use.  The same could be said for
the previous version of the example.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to