Scheduled Futures leak resources from Managed Executor Services on application stop #24293
Labels
Needs member attention
release bug
This bug is present in a released version of Open Liberty
release:23002
Describe the bug
The
futures
queue in ManagedScheduledExecutorServiceImpl holds references to scheduled futures, even once they have completed.The queue is periodically cleaned when new tasks are scheduled, by the private
purgeFutures()
method, but otherwise they are not actively removed, and it isn't called when applications are shutdown. As purgeFutures is private, applications can't call it themselves.There's also a deactivate method that aggressively cleans up when the server is shutdown.
Our application does a lot of work via scheduled tasks, and in a test/dev environment we want to stop and start the application without restarting the server. We do have other memory leaks that we're tracking down, but this one is making it harder to see what else is going on.
Steps to Reproduce
$Bar
class is observable, e.g. in JProfiler:You can see that the GC Root is via the
futures
queue inopen-liberty/dev/com.ibm.ws.concurrent/src/com/ibm/ws/concurrent/internal/ManagedScheduledExecutorServiceImpl.java
Line 63 in aa6a9f8
purgeFutures()
with reflectionExpected behavior
Resources should be released automatically when an application stops, as managed executors cannot be shutdown by application code, or there needs to be an explicit method to clean up. Waiting for 20 new tasks to be scheduled is unreliable.
Diagnostic information:
The text was updated successfully, but these errors were encountered: