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: remove memory leak from bind:this #11194

Merged
merged 9 commits into from
Apr 17, 2024
Merged

fix: remove memory leak from bind:this #11194

merged 9 commits into from
Apr 17, 2024

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Apr 16, 2024

This removes a nasty memory leak to do with bind:this. The PR also adds a runtime invariant for trying to create effects inside the teardown phase of an effect – as people shouldn't be creating new effects in something that's meant to be getting garbage collected.

Copy link

changeset-bot bot commented Apr 16, 2024

🦋 Changeset detected

Latest commit: 0b1a78a

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

@dummdidumm
Copy link
Member

dummdidumm commented Apr 16, 2024

Under what circumstance was this leaking memory? Always, because the effect is created in the cleanup phase of another effect?

@trueadm
Copy link
Contributor Author

trueadm commented Apr 16, 2024

Under what circumstance was this leaking memory? Always, because the effect is created in the cleanup phase of another effect?

Yep. Plus it was an effect, so it built a relationship with the signals.

@Rich-Harris
Copy link
Member

It really feels like creating effects inside teardown should be forbidden, even if that makes the implementation of bind:this slightly more finicky. Is there any place where it's necessary?

@trueadm
Copy link
Contributor Author

trueadm commented Apr 16, 2024

@Rich-Harris Agreed. Updated PR to add error for that use-case.

@trueadm
Copy link
Contributor Author

trueadm commented Apr 17, 2024

I've fixed the issues and came up with using the task queue instead which resolves of the issues and avoids us having to change that test.

@trueadm trueadm merged commit 63456f1 into main Apr 17, 2024
8 checks passed
@trueadm trueadm deleted the fix-memory-leak-2 branch April 17, 2024 08: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.

None yet

3 participants