jaxb
  1. jaxb
  2. JAXB-979

ClassFactory constructor cache could be more efficient

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: not determined
    • Fix Version/s: None
    • Component/s: runtime
    • Labels:
      None

      Description

      ClassFactory currently uses a ThreadLocal Map<Class,Constructor> in order to cache the default constructor lookups used in unmarshalling.

      issues:

      • The Cache is only valid with the current thread, thus each thread (possibly hundreds in an app server) has to populate it's own cache
      • Use of ThreadLocal's within an application server can lead to ClassLoader leaks, as each Thread can retain a reference to a ThreadLocal even though it is unreachable

      The common solution to the ThreadLocal issue is to call ClassFactory.clearCache() in a Servlet filter or similar which removes the ThreadLocal map.

      I propose (see mailing list for patch) that the cache can be implemented using a non locking copy on write algorithm that would will be the same or very close performance with a much reduced memory overhead (once populated) and better hit ratio.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Iaroslav Savytskyi
            Reporter:
            gadavis
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: