-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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 When Using Async Components #8740
Comments
I can submit a PR for the fix for this issue as well, thanks |
PR submitted here: #8755 |
Hi @LinusBorg I see you added some labels to this issue. Is there anything else that I need to do to kick off the review process of the referenced pull request? Thanks! |
f2009
pushed a commit
to f2009/vue
that referenced
this issue
Jan 25, 2019
…mpletes (fix vuejs#8740) (vuejs#8755) * fix(component): clean up memory leak after loading async component completes * fix(async component): accounting for async components with loading property * refactor(component): simplifying memory cleanup logic
aJean
pushed a commit
to aJean/vue
that referenced
this issue
Aug 19, 2020
…mpletes (fix vuejs#8740) (vuejs#8755) * fix(component): clean up memory leak after loading async component completes * fix(async component): accounting for async components with loading property * refactor(component): simplifying memory cleanup logic
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version
2.5.17
Reproduction link
https://codesandbox.io/s/4k43rylw0
Steps to reproduce
Load the reproducer and take a memory heap snapshot. Searching the heap you will find 4 VueComponents (App, Container, Child, Async Child)
Click the Destroy button. This toggles a v-if which will remove Child component and thus AsyncChild component as well.
At this point, the page is updated as expected
Take another memory heap snapshot. Search the heap again for "VueComponent" and you will see that 4 VueComponents still exist
What is expected?
After destroying Child component, the component and it's asynchronously loaded child component should be destroyed and the memory freed up.
What is actually happening?
Vue is holding on to a context reference which is preventing these components from being garbage collected
This is happening due to the resolve-async-component logic located here:
vue/src/core/vdom/helpers/resolve-async-component.js
Lines 57 to 68 in 52719cc
In the forceRender function on line 64, after calling $forceUpdate, the contexts array should be cleared to free up those references so that the components will be able to be garbage collected at a later point in time
The text was updated successfully, but these errors were encountered: