Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
2.0.7.Final
-
None
Description
jboss marshalling caches SerailizableClass instances using Java's ClassValue API. The intention here is to be able to weakly cache stuff using the java.lang.Class instance as the cache key while also referencing the java.lang.Class in the cache value (SerializableClass).
Unfortunately, the solution as it stands prevents ClassLoader garbage collection because SeriallzableClassRegistry keeps the ClassValue instance as a static variable which creates a hard reference chain between the ClassLoader and the ClassValue instance:
Some ClassLoader -> SerializableClassRegistry.class -> ClassValue instance
In this case, "Some ClassLoader" is a plugin/module class loader with an augmented class path compared to the System class loader.
The reason "Some ClassLoader" can't be GCed is because there is reference chain starting at the System Class loader that is preventing it that looks something like this:
System ClassLoader -> java.util.HashMap.class (this could be any Serializable class loaded by the System ClassLoader) -> classValueMap -> SerilizableClass.class (entry in the map) -> "Some ClassLoader" (it loaded SerializableClass)