RFR: 8304074: [JMX] Add an approximation of total bytes allocated on the Java heap by the JVM [v5]

David Holmes dholmes at openjdk.org
Tue May 9 01:07:25 UTC 2023


On Mon, 8 May 2023 14:03:18 GMT, Volker Simonis <simonis at openjdk.org> wrote:

>> src/hotspot/share/services/management.cpp line 2107:
>> 
>>> 2105:     // when result is initialized.
>>> 2106:     jlong result = ThreadService::exited_allocated_bytes();
>>> 2107:     for (JavaThreadIteratorWithHandle jtiwh; JavaThread *thread = jtiwh.next();) {
>> 
>> If you call `exited_allocated_bytes` whilst you have an active `ThreadsListHandle` then you at least ensure you don't miss accounting for threads that are just about to terminate.
>
> Do you mean something like:
> 
>     JavaThreadIteratorWithHandle jtiwh;
>     jlong result = ThreadService::exited_allocated_bytes();
>     while (JavaThread *thread = jtiwh.next()) {
>       ...
> 
> That would be fine for me. Otherwise I agree with the current compromise between accuracy and speed.

Yes. Though I realize my comment needed to make clear that you need a thread to update the count after it has removed itself from the thread-list, for this to be an improvement.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13814#discussion_r1188020260


More information about the hotspot-runtime-dev mailing list