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

fix(keep-alive): fix keep-alive memory leak #9875

Closed
wants to merge 2 commits into from
Closed

Conversation

dejour
Copy link
Contributor

@dejour dejour commented Apr 15, 2019

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:
Vue component will not be recycled. because keep-alive cache vnode. and cached vnode will hold on to new parent vnode which will hold created vue instance. So we will use the updated hook to set all
cached vnode's parent to null. This pull request will fix #9842. In the original issue. it states that it relates to transition which is not true. It can be any vue component.Here is my local test.
before:
before
the more you update keep-alive, the more hierarchy you get.
after:
after

@@ -120,5 +120,13 @@ export default {
vnode.data.keepAlive = true
}
return vnode || (slot && slot[0])
},
updated() {
const { cache } = this
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @dejour , just passing by and noticed that you can also destructure the _vnode property in this statemant, avoiding to use this._vnode on the line 127.

Also, the CI points a build failure on the test-cover and lint steps. I think it has nothing to do with your code, since the change it's not on you commit.

@posva
Copy link
Member

posva commented Jan 6, 2020

Thanks for the PR but we are closing this in favor of #9962

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Memory leak when using "transition" and "keep-alive"
3 participants