RFR: 8326820: Metadata artificially kept alive [v2]
Stefan Karlsson
stefank at openjdk.org
Wed Jun 19 09:06:15 UTC 2024
On Wed, 19 Jun 2024 06:14:21 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:
>> ClassLoaderDataGraph provides APIs for walking different metadata. All the iterators which are not designed to be used by the GC also keep the holder of the CLDs alive and by extensions keeps all metadata alive. This is problematic for concurrent GC as it keeps otherwise unreachable classes from being unloaded and the respective metadata freed.
>>
>> This patch changes the default iteration behaviour to not keep the holder alive, with the exception of `loaded_classes_do` (renamed `loaded_classes_do_keepalive`) and `modules_do` (renamed `modules_do_keepalive`) which is used by jvmti APIs that requires that the holder is kept alive.
>>
>> All other uses consumes all the metadata it queries during its safepoint or before releasing the `ClassLoaderDataGraph_lock`.
>>
>> Before this change some jcmd, new jfr chunks and some jfr events, all of which consumed these APIs, could cause class unloading to not occur.
>>
>> Been running our internal stress test in an even more stressful mode which without this patch reproduces the metaspace OOME [JDK-8326005](https://bugs.openjdk.org/browse/JDK-8326005) consistently within a few hours. And after this patch it does not.
>>
>> Currently running tier1-tier8 testing.
>
> Axel Boldt-Christmas has updated the pull request incrementally with one additional commit since the last revision:
>
> Document the iterator and functions
Looks good. One question below.
src/hotspot/share/classfile/systemDictionary.cpp line 1588:
> 1586: {
> 1587: MutexLocker ml(ClassLoaderDataGraph_lock);
> 1588: ClassLoaderDataGraph::methods_do_no_keepalive(f);
What about the call (SystemDictionary::methods_do), should we leave that name as-is or does it also need to be suffixed with no_keepalive?
-------------
Marked as reviewed by stefank (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/19769#pullrequestreview-2127563591
PR Review Comment: https://git.openjdk.org/jdk/pull/19769#discussion_r1645724854
More information about the hotspot-dev
mailing list