Am I cleaning up properly or am I creating a memory leak? #16108
Replies: 1 comment 1 reply
-
Calling the cleanup functions should generally be enough, otherwise there is a bug in the Svelte internals. Once the component is unmounted and its timers are expired, they should not be able to keep objects like the props alive. You also usually should not need When in doubt about memory issues, I recommend using the browser dev tools which usually are able to take memory snapshots and compare them, so you can see whether allocations are cleaned up correctly. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have the following snippet of code, which is written for an attempt to prevent a parent element from removing itself from the DOM as long as there is an element transitioning inside of it. I'm trying to achieve this using Svelte's features instead of relying on Promises.
To prevent creating more than one $effect, I tried the following approach, but I'm not sure whether I'm free of memory leaks here or not.
I'd be happy to know whether that's the case or not.
I'm cleaning up the callbackFunc passed to $effect.root by setting it to undefined, but I'm not sure whether I have to clean the $effect.root itself or not or whether there is actually any ways to do that. I'm worried that the internal logic of the $effect.root function itself might be getting called over and over again and stored somewhere in memory.
Beta Was this translation helpful? Give feedback.
All reactions