Skip to content

Commit fb1b3f5

Browse files
authored
fix(runtime): resolve memory leak caused by global content ref (#5266)
* fix(runtime): resolve memory leak caused by global content ref This commit resolves a memory leak in the runtime related to a global reference that existed in the vDOM algorithm. The content ref would get set when entering the render cycle for a component, but was never cleared so the reference would exist after execution STENCIL-1072 * resolve SNC
1 parent 0d61a53 commit fb1b3f5

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/runtime/vdom/vdom-render.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { h, isHost, newVNode } from './h';
1616
import { updateElement } from './update-element';
1717

1818
let scopeId: string;
19-
let contentRef: d.RenderNode;
19+
let contentRef: d.RenderNode | undefined;
2020
let hostTagName: string;
2121
let useNativeShadowDom = false;
2222
let checkSlotFallbackVisibility = false;
@@ -1127,6 +1127,9 @@ render() {
11271127
}
11281128
}
11291129
}
1130+
1131+
// Clear the content ref so we don't create a memory leak
1132+
contentRef = undefined;
11301133
};
11311134

11321135
// slot comment debug nodes only created with the `--debug` flag

0 commit comments

Comments
 (0)