Skip to content

Commit

Permalink
fix(core): do not mark FiberNode dominated by attached HTML element a…
Browse files Browse the repository at this point in the history
…s unmounted

Summary: This diff filters out a memory leak trace pattern: if a React FiberNode is dominated by an attached HTML DOM element. It is not considered as unmounted Fiber Node.

Reviewed By: tulga1970

Differential Revision: D49250856

fbshipit-source-id: 46bdaf7d4cfb12e1d0b26e277483dccc2ba67fba
  • Loading branch information
JacksonGL authored and facebook-github-bot committed Sep 25, 2023
1 parent fdac330 commit 9b067a2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/core/src/lib/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,13 @@ function markDetachedFiberNode(node: IHeapNode): boolean {
// if a Fiber node whose dominator is neither root nor
// another Fiber node, then consider it as detached Fiber node
if (cur.dominatorNode && cur.dominatorNode.id !== 1) {
if (!isFiberNode(cur.dominatorNode)) {
if (
isDOMNodeIncomplete(cur.dominatorNode) &&
!isDetachedDOMNode(cur.dominatorNode)
) {
// skip the direct marking of detached DOM nodes here
// if the Fiber Node is dominated by an attached DOM element
} else if (!isFiberNode(cur.dominatorNode)) {
cur.markAsDetached();
}
}
Expand Down

0 comments on commit 9b067a2

Please sign in to comment.