dev@glassfish.java.net

Re: StubFactoryBCEImpl memory leak

From: Ken Cavanaugh <Ken.Cavanaugh_at_Sun.COM>
Date: Fri, 24 Apr 2009 12:16:22 -0700
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.