RFR: 8268406: Deallocate jmethodID native memory [v2]

David Holmes dholmes at openjdk.org
Tue Jun 17 12:51:29 UTC 2025


On Tue, 17 Jun 2025 12:29:03 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> src/hotspot/share/oops/instanceKlass.cpp line 2480:
>> 
>>> 2478: void InstanceKlass::make_methods_jmethod_ids() {
>>> 2479:   MutexLocker ml(JmethodIdCreation_lock, Mutex::_no_safepoint_check_flag);
>>> 2480:   jmethodID* jmeths = methods_jmethod_ids_acquire();
>> 
>> Technically you don't need acquire semantics here as this value is not used to then access other data. But I see this is the only getter API available.
>
> Yes, this does need an acquire getter outside the lock.  It's better to not have a non-acquire version to be possibly used by accident.

Acquire is only ever needed outside the lock. I don't like there only being acquire/release available generally speaking because it just confuses what memory operations are being synchronized.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25267#discussion_r2152188477


More information about the hotspot-dev mailing list