[External] : Re: Virtual thread memory leak because TrackingRootContainer keeps threads
Ron Pressler
ron.pressler at oracle.com
Thu Jul 11 15:33:26 UTC 2024
> On 11 Jul 2024, at 12:38, Michal Domagala <outsider404 at gmail.com> wrote:
>
> Regardless of the main issue, I understand that VT GC is problematic. JEP 444 is modified and GC paragraph is removed.
> VT created by Thread API is strongly referenced to avoid finalization problems
The reason for keeping a reference to virtual threads by default is not finalization but observability. The cost of holding a strong reference is near zero because we can rely on the same strong references in constructs such as Executors and StructuredTaskScope, while adding WeakReferences would come at a cost.
>
> What does it mean? I do not understand this paragraph. Will G1 clean VT or not?
In most cases it will not because we keep a reference to the thread for observability unless you turn that off with a system property.
— Ron
More information about the loom-dev
mailing list