RFR 8151486 : Class.forName causes memory leak
mandy.chung at oracle.com
Wed Oct 5 23:19:20 UTC 2016
> On Oct 5, 2016, at 4:02 PM, David Holmes <david.holmes at oracle.com> wrote:
> On 6/10/2016 8:55 AM, Mandy Chung wrote:
>> Note that PD is the protection domain of an initiating class that resolves a target type T. PD is kept in T’s class loader L. It’s not the protection domains of the classes defined by L. VM keeps its own cache of protection domains that have been validated with a resolved type. VM does not depend on ClassLoader::domains field to keep it alive. IIUC, it’s kept as a weak reference in VM which is what we want here.
> Okay but this will still affect the lifecycle of the PDs because without the strong reference in L, those weak references in the VM will quickly be cleared. I'm unclear what the implications of this might be, but I doubt regular short-lived tests would expose any issues.
There is no issue there.
PD will be GC’ed together when the classes along with its class loader are unloaded. These class loaders may be one or more and they are L1, L2 …. != L.
More information about the core-libs-dev