-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Memory leak on first route visit if component has single root with multiple children #730
Comments
npm list --depth=0 |
@posva Thx for looking into this! Count and memory appear to be stable but they aren't. Each route you open the first time contributes to a new baseline (as leak happens only on first visit). I have added a "case 4" route (which also leaks): (numbers = case view opened / GC'ed)
|
I tried again and the count is stable on my end, there is no memory leak. |
Thx for looking at it again @posva. Much appreciated.
I would says thats because everything that could leak in the example project already leaked ;-) Add e. g. just 5 more routes with 5k dom nodes each and there are an extra 25k Dom nodes hanging in memory forever without being used or GC’ed. What puzzles me: Why do cases 1 & 2 behaviour differ compared to 3 & 4 ? Is there a special reason I don’t see? |
Persists in vue-router 4.0.6 / vue 3.0.11 |
Persists in vue-router 4.0.10 / vue 3.1.4 |
Persists in vue-router 4.0.13 / vue 3.2.31 |
@MarMun I am experiencing this issue as well. Did you ever happen to understand more about it? |
@michaelperel Thx for reaching out. I gave it another thought and came up with these questions:
To answer that, I created another case: I wrapped case 4 inside the layout of case 2 (also tested case 1). Unfortunately the wrapped case 4 also leaks (we need to assume that any nested child (on any level?) can cause the leak)...
To verify that, I created yet another case 4 variation with 500 items instead of 100 items. The nodes leak from first visit as assumed (number of leaked nodes is depended of which case 4 variation was visited first). Based on the last observation another (crazy?) idea could be:
This kind of 'anti-leak'-wrapper could be abstracted / reused for all routes. Thoughts? |
@MarMun I haven't done as much investigation as you have, however, I am building an app where the landing page has a ton of DOM elements. When I profile the memory, after navigating around to different routes, the memory used by the first route is never reclaimed. I don't know if the issue is in vue router or vue core, so I don't know if an 'anti-leak' wrapper would work. However, my experience is the same as the issue that was just linked, so it looks like it is a problem in core. |
@michaelperel Thx for the update. I'll follow the mentioned issue even though I don't use |
Version
3.0.5
Reproduction link
https://github.com/MarMun/vue-memleak
Steps to reproduce
npm run servep
localhost:5000
)What is expected?
DOM nodes from previous route visit (to "Case 3") can be (manually) garbage collected
What is actually happening?
DOM nodes from previous route visit (to "Case 3") can NOT be (manually) garbage collected
Assumption
It seems that DOM nodes are not collectable by GC after first route visit if component has single root with multiple child's.
No mem leak: No single root. Multiple children (Case 1)
No mem leak: Single root with one children (Case 2)
MEM LEAK: Single root with multiple children (Case 3)
The text was updated successfully, but these errors were encountered: