Skip to content
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

v-once and "unmount callbacks", possible memory leak? #5154

Closed
CamilleDrapier opened this issue Dec 22, 2021 · 1 comment
Closed

v-once and "unmount callbacks", possible memory leak? #5154

CamilleDrapier opened this issue Dec 22, 2021 · 1 comment
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 🐞 bug Something isn't working

Comments

@CamilleDrapier
Copy link

CamilleDrapier commented Dec 22, 2021

Version

3.2.26

Reproduction link

codesandbox.io

Steps to reproduce

  • click on the "toggle" button at least twice

What is expected?

Console statements saying that the "OtherCmponent" is unmounted/destroyed are shown along with the "mounted" statements.

What is actually happening?

Only the mount statements are shown


This was behaving differently in vue2, as the "destroy callbacks" were called, see: https://codesandbox.io/s/lingering-water-j7g43

This might also be related to this external issue: intlify/vue-i18n#844 (I think I can see evidence of something similar with vue-router) and generally, it might introduce memory leaks when using Components that were not specifically written to account for the beforeUnmount/unmounted not being called.

Please do let me know if this is not an issue but just a documentation miss (is it specified somewhere or should it be?), or if this is just my misunderstanding.

@shining-mind
Copy link

shining-mind commented Apr 8, 2024

The v-memo=[] can be used as workaround, the Vue will call unmount for the components in the cached subtree.

UPD: a more obvious example of the bug. The unmount is not called as the result the global click listener is not removed.

jacobfogolyan pushed a commit to jacobfogolyan/vuejs-core that referenced this issue Jul 13, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jul 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 🐞 bug Something isn't working
Projects
None yet
3 participants