On Mon, 8 May 2023 14:03:18 GMT, Volker Simonis <simo...@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

Reply via email to