ReferenceQueue declared but not used in ThreadContainers (memory leak)?

Alan Bateman Alan.Bateman at oracle.com
Wed May 17 10:45:44 UTC 2023


On 16/05/2023 21:15, Alexey Gavrilov wrote:
> Thanks Alan for the prompt response!
> Please share the bug id when you created it. Hopefully it will be 
> fixed soon.
>
> Am I correct, this is basically a memory leak? That is, those weak 
> references will never be garbage collected, so the application can  
> eventually crash.

The bug is JDK-8308235 [1], PR coming.  Yes, it's the weak references 
aren't expunged from the registry. If the thread pool is explicitly 
shutdown or closed before dropping the reference then it will be 
removed, it's just the case where a thread pool is created and 
unreferenced without shutdown. This may explain why it hasn't been 
reported before now.  I checked the history and the original code was 
correct but some refactoring in mid-2021 meant it was re-added to use 
the 1-arg rather than 2-arg constructor.

-Alan

[1] https://bugs.openjdk.org/browse/JDK-8308235


More information about the loom-dev mailing list