Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Cell memory leak in signaled subscriptions #32

Merged
merged 1 commit into from
Feb 16, 2024
Merged

Conversation

wkok
Copy link
Collaborator

@wkok wkok commented Feb 16, 2024

When using input signals with subscriptions (layer 3 - materialized views) I've noticed gradually degraded responsiveness in a UI that subscribed to many of these form of subscriptions.

Upon investigation, and with the help of the Flutter Dev Tools, I've identified an issue that seemed to point to a memory leak of Cell instances:

devtools

And indeed after some debugging, I've confirmed that when re-dash subscriptions were used as input signals, they created new Cell instances each time the signal gets resolved to a new value, and the old Cell was not garbage collected (probably because it remained referenced by its original dependencies)

This is corrected in this PR by introducing a signal cache (a registry if you will, like we use for normal subscriptions registered with reg-sub, but only for subscription signals)

This is managed internally by re-dash (as with all other regsitries) no changes required to existing code.

Result is much better UI responsivenes that does not degrade over time, and Flutter Dev Tools agree:

image

@hti-andre
Copy link

🚀😎

@wkok wkok merged commit 58b11bb into main Feb 16, 2024
3 checks passed
@wkok wkok deleted the signal-cache branch February 16, 2024 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants