On Sat, 22 Jun 2024 00:18:43 GMT, Coleen Phillimore <cole...@openjdk.org> wrote:

>  The 'resolve' for the CLDG iterator was to temporarily keep that CLD from 
> being unloaded, in the short time that we're iterating on that particular CLD.

This is the crux of the problem. For concurrent GCs, if the 'resolve' is called 
during a concurrent marking the CLD will be "marked" alive, and will be 
considered live all the way until we start a new concurrent mark cycle. At that 
point, we'll try again to figure out if the CLD is dead. If you then again use 
the iterator during that concurrent marking, the cycle repeats. So, if you tend 
to use these iterators a lot, we'll never get the chance to unload the classes.

This patch tries to combat that, by changing the iterators. With the patch the 
iterators hands out objects that are not dead, but they are not considered part 
of the live object graph. You can use the oops (and its transitive closure) in 
the CLD as long as you block out safepoints. However, if you try to use them 
after blocking for a safepoint things will break because the objects are not 
guaranteed to be a part of the live object graph so nothing kept is keeping 
them alive. That's what the no-keepalive is intended to refer to.

It would be great if we could figure out a name that hints that the iterators 
are unsafe to use unless you have understood the above.

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

PR Comment: https://git.openjdk.org/jdk/pull/19769#issuecomment-2185885243

Reply via email to