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

fix: address derived memory leak on disconnection from reactive graph #11819

Merged
merged 9 commits into from
May 29, 2024

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented May 29, 2024

Fixes #11817.

It turns out that we weren't fully handling the disconnection of derived signals from the reactivity graph – resulting in cases where they could leak memory because they were not being removed from their dependency reactions array. However, removing ourselves from this array meant that any future changes might mean we need to reconnect the derived to the graph again – so we have to do some additional bookkeeping to make this work. Thankfully, we already have versioning because of unowned deriveds, we can use the versions to understand if the owned derived signal is dirty after being connected to the reactivity graph again – something we couldn't do in early permutations of the signal architecture – and likely why we hadn't addressed this in the same sense.

Copy link

changeset-bot bot commented May 29, 2024

🦋 Changeset detected

Latest commit: 64edec8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
@dummdidumm dummdidumm merged commit 36b270e into main May 29, 2024
8 checks passed
@dummdidumm dummdidumm deleted the fix-memory-leak- branch May 29, 2024 14:23
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.

Svelte 5: $derived inside component does not get cleaned up causing memory leak
2 participants