RFR: 8309761: Leak class loader constraints

Ioi Lam iklam at openjdk.org
Sun Jun 11 06:43:40 UTC 2023


On Sat, 10 Jun 2023 15:21:21 GMT, Zhengyu Gu <zgu at openjdk.org> wrote:

> Hi,
> 
> Yes, this fixes the bug, but I'm confused.
> 
> If `ConstraintSet` determines the lifetime of the `LoaderConstraint`s, then why isn't the type of `_constraints` `GrowableArray<LoaderConstraint>*`? `loaderConstraints.cpp:161` is the only place where we create `LoaderConstraint`s on the heap and also the only place where we call `add_constraint()`. I'd rather see that change, than adding code onto the destructor. Is there some reason that this can't be done?
> 
> Cheers, Johan

If we make it `GrowableArray<LoaderConstraint>*`, the management of `LoaderConstraint::_loaders` would be messy. E.g., if you do


{
   LoaderConstraint lc = _constraints->at(i);
   // lc.~LoaderConstraint() is called here
}


How do we know if `lc._loaders` should be freed or not?

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

PR Comment: https://git.openjdk.org/jdk/pull/14407#issuecomment-1586041460


More information about the hotspot-runtime-dev mailing list