Skip to content

Conversation

@trueadm
Copy link
Contributor

@trueadm trueadm commented Nov 26, 2024

This was an odd memory leak that I've been tracking for weeks. I made the discovery today whilst looking into another issue that it was to do with untrack. Specifically, we only attach a derived to the parent effect when we're in a non tracking context – however, because nested deriveds only recorded their parent as effect, it meant that nested deriveds were incorrectly being added to the same effect after each run.

Rather than have the awkwardly deal with removing a derived from the parent each time, and know that deriveds can only be created where they are declared, we can instead just make the parent of a derived by that of an effect or another derived.

@changeset-bot
Copy link

changeset-bot bot commented Nov 26, 2024

🦋 Changeset detected

Latest commit: b16eb5f

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

@Rich-Harris
Copy link
Member

preview: https://svelte-dev-git-preview-svelte-14443-svelte.vercel.app/

this is an automated message

@github-actions
Copy link
Contributor

Playground

pnpm add https://pkg.pr.new/svelte@14443

@trueadm trueadm merged commit 45417a3 into main Nov 26, 2024
11 checks passed
@trueadm trueadm deleted the untrack-leak branch November 26, 2024 19:18
@github-actions github-actions bot mentioned this pull request Nov 26, 2024
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.

4 participants