On Wed, 14 Oct 2020 05:18:23 GMT, Sergey Bylokhov <[email protected]> wrote:

> java.beans.Introspector is using a new cache mechanism since Java9 in 
> com.sun.beans.introspect.ClassInfo::CACHE which
> uses a SoftReference cache over the class, which makes the class "leak", 
> unless clearing the cache manually or
> collecting the SoftReference by the GC.  Note that this is not a pure "leak", 
> because the SoftReference will be
> collected if there is no enough memory on the system, but if the heap is big 
> enough then all objects referenced from
> the cached class will be in the memory.  The class has a reference to the 
> ClassLoader, and If the soft reference to the
> class is not collected by the GC, then the ClassLoader cannot be unloaded and 
> this block the jar file removing.
> The solution is to update the implementation of 
> Introspector.flushCaches()/flushFromCaches(Class) to clear the whole
> cache or the cache for the specific class.

Looks good.

-------------

Marked as reviewed by kizune (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/647

Reply via email to