RFR: 8304074: [JMX] Add an approximation of total bytes allocated on the Java heap by the JVM [v13]
David Holmes
dholmes at openjdk.org
Thu May 11 03:44:48 UTC 2023
On Wed, 10 May 2023 23:57:47 GMT, Paul Hohensee <phh at openjdk.org> wrote:
>> Please review this addition to com.sun.management.ThreadMXBean that returns the total number of bytes allocated on the Java heap since JVM launch by both terminated and live threads.
>>
>> Because this PR adds a new interface method, I've updated the JMM_VERSION to 4, but would be happy to update it to 3_1 instead.
>
> Paul Hohensee has updated the pull request incrementally with one additional commit since the last revision:
>
> 8304074: getTotalThreadAllocatedBytes name change, increment exited_allocated_bytes in ThreadService::remove_thread, add 64-bit atomic add for linux/bsd_x86, stub out for other platforms
src/hotspot/share/services/management.cpp line 2107:
> 2105: // twice, once in the loop and agsin in exited_allocated_bytes if it's
> 2106: // removed from the list after it's encountered in the loop but before
> 2107: // adding exited_allocated_bytes.
This is not an accurate description.
Once we have the TLH we have a fixed set of threads and none of them can update exited_allocated_bytes. If we read exited_allocated_bytes while the TLH is held then the count can be short for two reasons:
1. Newly started threads
2. Terminating threads that already escaped the TLH but which hadn't updated exited_allocated_bytes by the time we read it.
AFAICS with the current logic there is no possibility of double-accounting.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13814#discussion_r1190602862
More information about the hotspot-runtime-dev
mailing list