RFR: 8299426: Heap dump does not contain virtual Thread stack references [v2]

Alan Bateman Alan.Bateman at oracle.com
Mon Dec 4 13:20:59 UTC 2023



On 04/12/2023 12:41, David Holmes wrote:
> On 1/12/2023 2:08 pm, Alex Menkov wrote:
>> On Thu, 30 Nov 2023 21:11:08 GMT, Chris Plummer 
>> <cjplummer at openjdk.org> wrote:
>>
>>> I wasn't thinking in terms of the scheduler somehow no longer 
>>> references the virtual thread, but instead the program no longer 
>>> referencing the scheduler (and also not referencing the virtual 
>>> thread).
>>
>> AFAIU unfinished unmounted virtual threads are referenced from other 
>> objects (they are parked on), so they can't be unreachable even is 
>> the application is not referencing them and the scheduler.
>
> There is (or was - there may be a property that affects this: 
> trackAllThreads?) a scenario where a VT might park on a 
> synchronization object which is not referenced from any other thread. 
> The VT can never be unparked, and the sync object and the VT are 
> reachable only from either other and so both can be GC'd.

That's right, the door is not closed to introducing ephemeral threads in 
the future. Right now, virtual threads created directly with the Thread 
API remaining strongly reachable once started until they terminate. 
Virtual threads created in other containers (e.g. a thread-per-task 
ExecutorService) are kept reachable by the container.

-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/serviceability-dev/attachments/20231204/90cc8f06/attachment.htm>


More information about the serviceability-dev mailing list