[External] : Re: Virtual thread memory leak because TrackingRootContainer keeps threads

robert engels robaho at icloud.com
Tue Jul 23 12:49:22 UTC 2024


Ok, but since the virtual thread scheduler needs to schedule them, they would always be reachable unless the reference used by the scheduler was outside GC or weak, and then though if they are not a GC root as soon as they are created they would be collected or the user code would need to keep a reference to every VT it creates. 

None of these cases feel like existing platform threads - nor do they feel easy to read on about. 

> On Jul 23, 2024, at 4:08 AM, Andrew Haley <aph-open at littlepinkcloud.com> wrote:
> 
> On 7/22/24 23:24, robert engels wrote:
>> But even if VT threads are not GC roots, a GC root must have a reference
>>  to them, right?
> 
> Yes.
> 
>> (to the Loom team) Otherwise they would be immediately collected.
> 
> Which would be good, because if a virtual thread is not reachable from any
> root, then it will never run (because no one can reach it.) So let's
> immediately collect it.
> 
> --
> Andrew Haley  (he/him)
> Java Platform Lead Engineer
> Red Hat UK Ltd. <https://www.redhat.com>
> https://keybase.io/andrewhaley
> EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
> 


More information about the loom-dev mailing list