Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

ClassFactory constructor cache could be more efficient #979

Open
glassfishrobot opened this issue Sep 16, 2013 · 3 comments
Open

ClassFactory constructor cache could be more efficient #979

glassfishrobot opened this issue Sep 16, 2013 · 3 comments

Comments

@glassfishrobot
Copy link
Contributor

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.

Affected Versions

[not determined]

@glassfishrobot
Copy link
Contributor Author

Reported by gadavis

@glassfishrobot
Copy link
Contributor Author

Was assigned to yaroska

@glassfishrobot
Copy link
Contributor Author

This issue was imported from java.net JIRA JAXB-979

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant