From 3867bb4c14131ef94098a62bffba97a5b7d1fe66 Mon Sep 17 00:00:00 2001 From: Bas van Meurs Date: Sat, 5 Dec 2020 00:03:10 +0100 Subject: [PATCH] fix(runtime-core): component mount anchor memory leak (#2459) fix #2458 --- packages/runtime-core/src/renderer.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/runtime-core/src/renderer.ts b/packages/runtime-core/src/renderer.ts index 3baaf2405ea..da86040d0a1 100644 --- a/packages/runtime-core/src/renderer.ts +++ b/packages/runtime-core/src/renderer.ts @@ -1395,8 +1395,9 @@ function baseCreateRenderer( } // onVnodeMounted if ((vnodeHook = props && props.onVnodeMounted)) { + const scopedInitialVNode = initialVNode queuePostRenderEffect(() => { - invokeVNodeHook(vnodeHook!, parent, initialVNode) + invokeVNodeHook(vnodeHook!, parent, scopedInitialVNode) }, parentSuspense) } // activated hook for keep-alive roots. @@ -1410,6 +1411,9 @@ function baseCreateRenderer( queuePostRenderEffect(a, parentSuspense) } instance.isMounted = true + + // #2458: deference mount-only object parameters to prevent memleaks + initialVNode = container = anchor = null as any } else { // updateComponent // This is triggered by mutation of component's own state (next: null)