Replies: 2 comments 3 replies
-
I'll look into it :) EDIT: Actually had a in progress PR that solves it entirely, I just got busy and never opened it. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Beta Was this translation helpful? Give feedback.
3 replies
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.
-
Following #4287 I did some additional research and discovered the following, pretty serious memory leak related to the
x-if
andx-for
directives.Consider a situation in which two (or more) x-ifs or x-fors are nested. Whenever the expression of the outer directive changes in such a way that content gets removed, watchers and effects that are defined inside the inner directive are not cleaned up and stay in memory indefinitely.
Minimal example:
This behavior can be reproduced in a variety of combinations, using
x-if
,x-for
,x-effect
and$watch
. Thecleanup()
method of custom directives does not get called either. Here are some examples:This might seem like a minor issue at first. But please consider larger apps, especially single page apps. Nesting these structures is not too uncommon. In fact, I inspected memory in a larger such app that my team develops. The app quickly piles up hundreds of MB of memory due to all kinds of data not being garbage collected just by navigating from page to page.
We have not yet managed to get to the bottom of this issue in the Alpine codebase. Any insights or potential fixes from people who are more familiar with the codebase would be very much appreciated!
Beta Was this translation helpful? Give feedback.
All reactions