RFR: 8264682: MemProfiling does not own Heap_lock when using G1
Ioi Lam
iklam at openjdk.java.net
Mon Apr 5 22:48:25 UTC 2021
On Mon, 5 Apr 2021 14:29:11 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
> > Trivial fix for JDK-8264682.
>
> No, not trivial at all. Dropping a GC-specific blob like this into shared code is highly questionable. I'm not sure how this issue should be addressed, but I don't think the proposed change is the right approach.
It looks like the following APIs can be reliably called without holding the Heap_lock. However, I am not sure if they would give the same result. I.e., can you get `Universe::heap()->unused()` by calling `Universe::heap()->capacity() - Universe::heap()->unused()`.
JVM_ENTRY_NO_ENV(jlong, JVM_TotalMemory(void))
size_t n = Universe::heap()->capacity();
return convert_size_t_to_jlong(n);
JVM_END
JVM_ENTRY_NO_ENV(jlong, JVM_FreeMemory(void))
size_t n = Universe::heap()->unused();
return convert_size_t_to_jlong(n);
JVM_END
-------------
PR: https://git.openjdk.java.net/jdk/pull/3340
More information about the hotspot-runtime-dev
mailing list