Uploaded image for project: 'Axis'
  1. Axis
  2. AXIS-2674

MethodCache does not clean properly, leading to classloader leaking

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • 1.3, 1.4
    • None
    • Basic Architecture

    Description

      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(); }

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              tchize David Delbecq
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: