Skip to content

Commit e0747f4

Browse files
committed
fix(keep-alive): fix memory leak without breaking transition tests
1 parent 2632249 commit e0747f4

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/core/components/keep-alive.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,15 @@ function matches(
3333
}
3434

3535
function pruneCache(
36-
keepAliveInstance: { cache: CacheEntryMap; keys: string[]; _vnode: VNode },
36+
keepAliveInstance: {
37+
cache: CacheEntryMap
38+
keys: string[]
39+
_vnode: VNode
40+
$vnode: VNode
41+
},
3742
filter: Function
3843
) {
39-
const { cache, keys, _vnode } = keepAliveInstance
44+
const { cache, keys, _vnode, $vnode } = keepAliveInstance
4045
for (const key in cache) {
4146
const entry = cache[key]
4247
if (entry) {
@@ -46,6 +51,7 @@ function pruneCache(
4651
}
4752
}
4853
}
54+
$vnode.componentOptions!.children = undefined
4955
}
5056

5157
function pruneCacheEntry(

src/core/vdom/create-component.ts

-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ const componentVNodeHooks = {
6262
vnode, // new parent vnode
6363
options.children // new children
6464
)
65-
// #12187 unset children reference after use to avoid memory leak
66-
options.children = undefined
6765
},
6866

6967
insert(vnode: MountedComponentVNode) {

0 commit comments

Comments
 (0)