RFR: 8304074: [JMX] Add an approximation of total bytes allocated on the Java heap by the JVM [v23]
David Holmes
dholmes at openjdk.org
Tue May 23 02:31:58 UTC 2023
On Fri, 19 May 2023 13:54:13 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: atomic load needed in exited_allocated_bytes
src/hotspot/share/services/management.cpp line 2104:
> 2102: // the final result can only be short due to (1) threads that start after
> 2103: // the TLH is created, or (2) terminating threads that escape TLH creation
> 2104: // and don't update exited_allocated_bytes before we initialize result.
Okay this is why you can't do monotonicity check in the tests. Imagine we have 10 threads all live and we call this function and so tally up all 10 threads. The next time we call this 5 of the threads are in the process of terminating - they have escaped the TLH but not yet updated the exited_allocated_bytes - so now we only tally up 5 threads and so the total appears to be far less than last time.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13814#discussion_r1201428147
More information about the serviceability-dev
mailing list