dev@glassfish.java.net

Re: StubFactoryBCEImpl memory leak

From: Roman Pokhodzhai <rpohod_at_gmail.com>
Date: Fri, 24 Apr 2009 23:36:21 +0300

Find attached.

On Fri, Apr 24, 2009 at 10:16 PM, Ken Cavanaugh <Ken.Cavanaugh_at_sun.com>wrote:

> Roman Pokhodzhai wrote:
>
> Salut,
>
> I found that StubFactoryBCEImpl (actually StubFactoryDynamicBase) has
> reference to classloader. And sometimes it's application classloader. Hence,
> application cant be undeployed completely and OutOfMemoryExceptions occurs.
>
> Have anybody an idea how to solve it?
>
> The StubFactory is part of the ClassData which is stored in the
> PresentationManager in a WeakHashMap
> classToClassData, which has as its key the class. I think this is the only
> reference to the StubFactory that
> is held from a GC root.
>
> There probably is a problem here, but not with the ClassLoader reference:
> rather, look at
> PresentationManagerImpl.ClassDataImpl. This is the value in WeakHashMap
> classToClassData,
> which contains a strong reference to the class key. This may be causing a
> problem, due to the
> discussion in the WeakHashMap javadoc about this problem.
>
> However, we have also added code in the EJB layer to flush entries out of
> the
> cache by calling flushClass. This happens in
> com.sun.ejb.containers.BaseContainer, where
> various EJB classes are cleaned up by calling cleanupClass, which in turn
> calls
> flushClass in the ORB code.
>
> Do you have some evidence (or better yet, a heap dump) of this causing a
> memory leak?
>
> Thanks,
>
> Ken.
>
>