Virtual thread memory leak because TrackingRootContainer keeps threads
Michal Domagala
outsider404 at gmail.com
Mon Jul 1 19:08:13 UTC 2024
According to https://openjdk.org/jeps/444,
"Unlike platform thread stacks, virtual thread stacks are not GC roots."
But jdk.internal.vm.ThreadContainers.RootContainer.TrackingRootContainer#VTHREADS
keeps (hard) references to each virtual thread. Effectively,
virtual threads are GC roots.
I described full example here:
https://stackoverflow.com/questions/78596905/why-virtual-thread-is-not-garbage-collected-when-not-reachable
The problem was not visible since
https://bugs.openjdk.org/browse/JDK-8309406, because before the change,
VTHREADS "keep" was not enabled and i guess nobody cares memory leak.
But after the change every JVM is affected.
A workaround for memory leak is set jdk.trackAllThreads=false
Best regards
Michal Domagala
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20240701/13b2109e/attachment.htm>
More information about the loom-dev
mailing list