RFR: 8297638: Memory leak in case of many started-dead threads [v2]
Chris Plummer
cjplummer at openjdk.org
Tue Feb 7 02:28:47 UTC 2023
On Tue, 7 Feb 2023 02:23:43 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:
>> src/jdk.jdi/share/classes/com/sun/tools/jdi/VMState.java line 184:
>>
>>> 182: // We always need to clear the ReferenceQueue
>>> 183: while (listenersReferenceQueue.poll() != null)
>>> 184: ;
>>
>> I'm not sure how does this work.
>> Do we keep polling if there is any reference object in the queue?
>> Can it be an endless loop? Does the poll() remove the reverence object from the queue?
>
> The poll() removes the next object from the queue.
This code is a bit odd in that it uses the reference queue to find out if there are one or more unreachable listeners. If there are, then it uses the code below to remove them. So the reference queue is really just a unreachable object detection mechanism, and not used for the actual processing of the objects.
-------------
PR: https://git.openjdk.org/jdk/pull/12081
More information about the serviceability-dev
mailing list