Skip to content

Commit

Permalink
fix(runtime): resolve memory leak caused by global content ref (#5266)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
tanner-reits committed Jan 17, 2024
1 parent 0d61a53 commit fb1b3f5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/runtime/vdom/vdom-render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { h, isHost, newVNode } from './h';
import { updateElement } from './update-element';

let scopeId: string;
let contentRef: d.RenderNode;
let contentRef: d.RenderNode | undefined;
let hostTagName: string;
let useNativeShadowDom = false;
let checkSlotFallbackVisibility = false;
Expand Down Expand Up @@ -1127,6 +1127,9 @@ render() {
}
}
}

// Clear the content ref so we don't create a memory leak
contentRef = undefined;
};

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

0 comments on commit fb1b3f5

Please sign in to comment.