Details
-
Improvement
-
Resolution: Fixed
-
Major
-
17.10.0
-
None
-
Unit
-
Unknown
-
N/A
-
N/A
-
Description
DefaultBeanManager caches the BeanDescriptor computed for each bean class in a SoftCache, a map with soft keys and values protected by a read/write lock, introduced in XCOMMONS-1481 so that the cache doesn't prevent classes coming from extensions or scripts from being garbage collected.
The JDK provides a dedicated mechanism for associating a computed value with a class: java.lang.ClassValue. Using it simplifies the code:
- The descriptor is stored in the Class object itself, so it is released exactly when the class (and its class loader) is garbage collected, instead of being held through soft references until the JVM runs short of memory, which could keep classes of an old class loader in the cache.
- Lookups are lock-free and the descriptor is computed once per class: when several threads compute it concurrently, all of them get the same instance.
No behavior change is expected; this issue exists for traceability.
Attachments
Issue Links
- relates to
-
XCOMMONS-1481 Potential memory leak in org.xwiki.properties.internal.DefaultBeanManager
-
- Closed
-
-
XCOMMONS-3937 Concurrent requests block each other when resolving entity references
-
- Open
-