RFR: 8318720: G1: Memory leak in G1CodeRootSet after JDK-8315503 [v2]
Zhengyu Gu
zgu at openjdk.org
Wed Oct 25 13:34:38 UTC 2023
On Wed, 25 Oct 2023 12:14:29 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:
>> src/hotspot/share/gc/g1/g1CodeRootSet.cpp line 164:
>>
>>> 162: Atomic::store(&_num_entries, (size_t)0);
>>> 163: }
>>> 164: _table.unsafe_reset();
>>
>> Thanks for catching this!
>>
>> I believe something like a call to `_table.clean([] (nmethod** value) { return true; });` should do roughly the same. (It is fine to name the lambda with something meaningful, like `always_true`. Or `delete_all`. `do_value` is just too unspecific to me).
>
> Another option is to provide a reset function in the CHT itself that roughly does what the destructor does right now.
That's the first place I looked. But `free_nodes` is not MT-safe, I am not sure it will fit well with other APIs that all seem to be MT-safe.
I also thought about move `G1CodeRootSetHashTable::clear()` implementation to CHT, but likely I would need another version for safepoint? (e.g. use `_table.bulk_delete` instead).
Hope to have a chance to return to JVM development fulltime, so I will have time to think about it. For now, I will let you to worry about the refactoring :-)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16352#discussion_r1371769768
More information about the hotspot-gc-dev
mailing list