[External] : Re: Virtual thread memory leak because TrackingRootContainer keeps threads
Ron Pressler
ron.pressler at oracle.com
Thu Aug 1 17:11:23 UTC 2024
> On 1 Aug 2024, at 10:41, robert engels <robaho at icloud.com> wrote:
>
> I was not aware of that! So are you saying that current JVMs will GC or not even create A in the following:
>
> A a = …
> while(true) {
> …never reference A…
> }
> a.doSomething();
>
That depends on whether or not the VM is able to prove that the loop can never be exited (or if it is, then only through an exception that won’t be caught before a.doSomething, which also depends on the inference power of the implementation. But if the VM could prove that, then the object referenced by A is allowed to be collected (that is exactly what ReachabilityFence is for, although that API has some problems we won’t get into here).
The rule is that when you access an object through a strong reference it will be there. The converse is that the VM may collect an object that will provably never be accessed through a strong reference. The rest is implementation details (and ReachabilityFence, which is problematic in multiple ways, including in how it’s specified).
— Ron
More information about the loom-dev
mailing list