RFR 8151486 : Class.forName causes memory leak

David Holmes david.holmes at oracle.com
Wed Oct 5 23:02:56 UTC 2016


On 6/10/2016 8:55 AM, Mandy Chung wrote:
>
>> On Oct 5, 2016, at 2:26 PM, David Holmes <david.holmes at oracle.com> wrote:
>>
>> On 6/10/2016 6:19 AM, Mandy Chung wrote:
>>>
>>>
>>> Since domains is not used and not intended to keep PD alive and VM maintains its own cache of these initiating PD for performance, removing domains field looks good to me.
>>
>> What then is intended to keep PD alive? Or do we not need to keep them alive?
>>
>> I have always assumed that domains was used to keep the PD alive for as long as the classloader is alive.
>
>
> 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.

David
-----

> Brent did the archeology and found that the initial fix introduced the domains field attempted to use it.  But the initial fix was back out and reimplemented and domains is not used.  In any case, this field is not used and depended by VM.
>
> Mandy
>


More information about the hotspot-dev mailing list