-
I'm trying to understand the potential for memory leaks in Alpine.js when using the I took a look at the What are people using for general guide-lines in terms of releasing effects? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 14 replies
-
x-effect cleans it up (though you make me worry). the The effect will stick around so long as the data exists. And you can potentially get into contexts where effects and data make a web of stuff where only one thing is directly used but it keeps a bunch of stuff around. You should clean up your manually created effects (with |
Beta Was this translation helpful? Give feedback.
-
Just for cross-reference, this came up in my blog post about creating an |
Beta Was this translation helpful? Give feedback.
x-effect cleans it up (though you make me worry). the
effect
utility passed to directives auto registers the release to the cleanup of the directive.The effect will stick around so long as the data exists.
And you can potentially get into contexts where effects and data make a web of stuff where only one thing is directly used but it keeps a bunch of stuff around.
You should clean up your manually created effects (with
Alpine.effect
) once you no longer need them. It will be much harder to hunt down the cause of such a web of effects if you just ignore it for later.