Skip to content

Conversation

oliver-sanders
Copy link
Member

@oliver-sanders oliver-sanders commented Sep 10, 2025

Fix a memory leak found in the resolver code.

cylc.flow.network.resolvers.BaseResolvers.delta_processing_flows is added to for each subscription. However, it seems never to be removed from.

There is the BaseResolvers.flow_delta_processed method (called from the UIS side) which housekeeps things within each entry. I'm not sure if this was intended to remove the entry for each subscription too. But I'm also not sure if this method would get called in the event of an exception, namely GeneratorExit.

Reproducible Example

diff --git a/cylc/flow/network/resolvers.py b/cylc/flow/network/resolvers.py
index 77e602d26..d24e0d450 100644
--- a/cylc/flow/network/resolvers.py
+++ b/cylc/flow/network/resolvers.py
@@ -516,6 +516,8 @@ class BaseResolvers(metaclass=ABCMeta):  # noqa: SIM119
         yielded GraphQL subscription objects.
 
         """
+        print('#', len(self.delta_processing_flows))
+
         # NOTE: we don't expect workflows to be returned in definition order
         # so it is ok to use `set` here
         workflow_ids = set(args.get('workflows', args.get('ids', ())))
# ~/.cylc/uiserver/jupyter_config.py

c.ServerApp.websocket_ping_interval = 3
c.ServerApp.websocket_ping_timeout = 0.000001

Before (objects not cleaned up):

$ cylc gui --new  # let it open to the Dashboard page
# 0
# 1
# 2
# 3
...

After (objects cleaned up):

$ cylc gui --new  # let it open to the Dashboard page
# 0
# 0
# 0
# 0
...

Check List

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Applied any dependency changes to both setup.cfg (and conda-environment.yml if present).
  • Tests are included (or explain why tests are not needed).
  • Changelog entry included if this is a change that can affect users
  • Cylc-Doc pull request opened if required at cylc/cylc-doc/pull/XXXX.
  • If this is a bug fix, PR should be raised against the relevant ?.?.x branch.

Comment on lines +632 to +633
if sub_id in self.delta_processing_flows:
del self.delta_processing_flows[sub_id]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dwsutherland, do you know if it makes sense to delete the entry here or should be cleared elsewhere in the code?

@oliver-sanders oliver-sanders modified the milestones: 8.5.x, 8.6.x Oct 2, 2025
@oliver-sanders oliver-sanders changed the base branch from 8.5.x to 8.6.x October 2, 2025 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant