RFR 8151486 : Class.forName causes memory leak
mandy.chung at oracle.com
Wed Oct 5 22:55:20 UTC 2016
> 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.
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.
More information about the core-libs-dev