You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Thomas �hlen <th...@obidobi.net> on 2002/02/19 15:53:16 UTC
BUG? References to old WebappClassLoaders never released.
To summarize the problem:
I had a memory leak when using Tomcats manager to reload my application.
Analyzing the situation i found that Singeltons are never GC'd. Why? Looking
deeper there seems to be a problem with old WebappClassLoaders never getting
GC'd and the reason seems to be that there are references to the
WebappClassLoaders that never get removed.
See here for more information:
http://nyx.obidobi.net/~thomas/tomcat/index.html
I have located the problem to:
static Hashtables (clBindings, clNameBindings ) located in class
org.apache.naming.ContextBindings.
The classLoaders are added to these Hashtables by a call from
lifecycleEvent in the class NamingContextListner.java
=============>
NamingContextListner.java, 295
if (container instanceof Context) {
// Setting the context in read only mode
ContextAccessController.setReadOnly(getName());
try {
ContextBindings.bindClassLoader
(container, container,
((Container)
container).getLoader().getClassLoader());
} catch (NamingException e) {
log(sm.getString("naming.bindFailed", e));
}
}
<============
I think that there should be a call to unbindClassLoader in the following
code
NamingContextListner.java, 325
} else if (event.getType() == Lifecycle.STOP_EVENT) {
if (!initialized)
return;
// Setting the context in read/write mode
ContextAccessController.setWritable(getName(), container);
New line ===> ContextBindings.unbindClassLoader( container, container );
ContextAccessController.unsetSecurityToken(getName(),
container);
namingContext = null;
envCtx = null;
compCtx = null;
initialized = false;
}
}
Thomas
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: BUG? References to old WebappClassLoaders never released.
Posted by Remy Maucherat <re...@apache.org>.
> To summarize the problem:
>
> I had a memory leak when using Tomcats manager to reload my application.
> Analyzing the situation i found that Singeltons are never GC'd. Why?
Looking
> deeper there seems to be a problem with old WebappClassLoaders never
getting
> GC'd and the reason seems to be that there are references to the
> WebappClassLoaders that never get removed.
Yes, that's a good analysis.
I'll apply the patch.
Thanks,
Remy
> See here for more information:
>
> http://nyx.obidobi.net/~thomas/tomcat/index.html
>
> I have located the problem to:
>
> static Hashtables (clBindings, clNameBindings ) located in class
> org.apache.naming.ContextBindings.
>
> The classLoaders are added to these Hashtables by a call from
> lifecycleEvent in the class NamingContextListner.java
>
> =============>
> NamingContextListner.java, 295
>
> if (container instanceof Context) {
> // Setting the context in read only mode
> ContextAccessController.setReadOnly(getName());
> try {
> ContextBindings.bindClassLoader
> (container, container,
> ((Container)
> container).getLoader().getClassLoader());
> } catch (NamingException e) {
> log(sm.getString("naming.bindFailed", e));
> }
> }
>
> <============
>
> I think that there should be a call to unbindClassLoader in the following
> code
>
> NamingContextListner.java, 325
>
> } else if (event.getType() == Lifecycle.STOP_EVENT) {
>
> if (!initialized)
> return;
>
> // Setting the context in read/write mode
> ContextAccessController.setWritable(getName(), container);
>
> New line ===> ContextBindings.unbindClassLoader( container,
container );
>
> ContextAccessController.unsetSecurityToken(getName(),
> container);
>
> namingContext = null;
> envCtx = null;
> compCtx = null;
> initialized = false;
>
> }
> }
>
> Thomas
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>