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

Open
wants to merge 1 commit into
base: dev
from

Conversation

Projects
None yet
2 participants
@dejour
Copy link
Contributor

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

This comment has been minimized.

Copy link
@hugoazevedosoares

hugoazevedosoares Apr 18, 2019

Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.