-
Enhancement
-
Resolution: Won't Do
-
Major
-
3.0.12, 4.0.2
-
None
Class LoadCache keeps a map of known, loaded classes using a nested map hierarchy. The outer map is indexed by classloader and each entry links to a secondary map. The secondary maps are indexed by classname and link to a Class<?> loaded by the corresponding classloader or one of its parents.
The outer map is a WeakHashMap<ClassLoader, HashMap> which is intended to ensure that entries are released when all references to a loader and its classes have been dropped. However, this is insufficient to achieve this because the inner map is a HashMap<String, Class<?>>. When a inner map M_CL keyed by loaded CL includes an entry for a class C loaded by CL (which is the normal case) then the reference to C from M_CL will keep CL alive, stopping CL from being unloaded.
The inner maps really need to employ some form of weak reference to the classes embedded in their entries so that this reference cycle can be broken.
- is related to
-
BYTEMAN-367 LoadCache is degrading rather than improving performance
- Resolved