Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-10513

ReflectionUtils::CONSTRUCTOR_CACHE leaks class loaders

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.4.0
    • None
    • util

    Description

      Any code which uses custom class-loaders needs to be aware of the ReflectionUtils::CONSTRUCTOR_CACHE

       /** 
         * Cache of constructors for each class. Pins the classes so they
         * can't be garbage collected until ReflectionUtils can be collected.
         */
        private static final Map<Class<?>, Constructor<?>> CONSTRUCTOR_CACHE = 
          new ConcurrentHashMap<Class<?>, Constructor<?>>();
      

      This is not a problem when using only 1 AppClassLoader.

      But in cases where the application uses multiple classloaders (to isolate UDFs), this holds onto class references and their associated class loaders by ref (& that leaks all the statics).

      The clear method for this cache is unfortunately marked only for testing.

        // methods to support testing
        static void clearCache() {
          CONSTRUCTOR_CACHE.clear();
        }
      

      The cache shows up as the only reference for the class loaders.

      Attachments

        1. class-loader-leak.png
          140 kB
          Gopal Vijayaraghavan

        Issue Links

          Activity

            People

              Unassigned Unassigned
              gopalv Gopal Vijayaraghavan
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated: