A DESCRIPTION OF THE REQUEST :
It is not possible (without using reflection) to clear the references held in ObjectStreamClass$Caches. Such a use of reflection is strongly discouraged in Java 9 onwards.
A method is requested that removes all classes from the caches that have been loaded by the given class loader or a descendant.
One of the features of Apache Tomcat is detection of memory leaks in web applications. For this detection to work, it is necessary that all valid/expected references to a web application class loader can be removed. A combination of a WeakReference to the web application class loader and an explicit GC call then enables Tomcat to determine if any unexpected references have been retained to the web application class loader which would indicate a memory leak.
The references retained in ObjectStreamClass$Caches trigger a false positive in Tomcat's memory leak detection. It is necessary to clear those references for the detection to work correctly. An API to do this is requested.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Something along the lines of this API:
that then did the equivalent of cleanUpLeakingObjects() in https://github.com/markt-asf/memory-
The clean-up has to be performed via reflection.
---------- BEGIN SOURCE ----------
This class demonstrates the leak:
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
See the code in cleanUpLeakingObjects()