You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "David Delbecq (JIRA)" <ax...@ws.apache.org> on 2007/06/08 14:08:26 UTC

[jira] Created: (AXIS-2674) MethodCache does not clean properly, leading to classloader leaking

MethodCache does not clean properly, leading to classloader leaking
-------------------------------------------------------------------

                 Key: AXIS-2674
                 URL: https://issues.apache.org/jira/browse/AXIS-2674
             Project: Axis
          Issue Type: Bug
          Components: Basic Architecture
    Affects Versions: 1.3, 1.4
            Reporter: David Delbecq
            Priority: Critical


In org.apache.axis.utils.cache.MethodCache, the cache is handled using ThreadLocals. That mean each Thread calling MethodCache has it's own cache. However, the method 

    public void clearCache() {
        Map map = (Map) cache.get();
        if (map != null) {
            map.clear();
        }
    }

This only reset the cache of current Thread. Other Thread's cache are left untouched. This is a problem in an environment like tomcat, where the clearCache() will be called by one Thread at webapp undeploy while the caches have been created for various calling Http-Thread. Those HttpThread now contains via ThreadLocal implicit reference to content of cache, which contains references to classes which themself contains natural reference to their classloader. As such, unless you discard all Http Threads, it's impossible to garbage collect content of caches and as such the webapp classloader that is referenced by them is not garbage collected. This result in whole webapplication not garbage collected at undeploy.

Possible solutions to clean whole cache:
1)
    public void clearCache() {
        cache = null;
    }

2)
    public void clearCache() {
        cache = new ThreadLocal();
    }



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org