Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V18 2 0 with memory fixes #4

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Conversation

hellsan631
Copy link
Member

Be always more aggro with cleaning up references to dom nodes in state.

Comment on lines -1376 to -1382
if (fiber.tag === HostComponent) {
const hostInstance: Instance = fiber.stateNode;
if (hostInstance !== null) {
detachDeletedInstance(hostInstance);
}
}
fiber.stateNode = null;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abstracting this to detatchFiberStateNode so we can try to run this in a couple of different places.

// tree, which has its own pointers to children, parents, and siblings.
// The other host nodes also point back to fibers, so we should detach that
// one, too.
detatchFiberStateNode(fiber);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always doing this instead of only doing this in certain cases.

}
fiberToDetach.stateNode = null;

if (fiberToDetach.alternate !== null) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding, fiber.alternate is the Fiber that stores future/new work. Not all fibers will have future work, but if we're unmounting a fiber, we should be sure to cleanup the "future" state too.

@@ -47,11 +47,35 @@ export function detachDeletedInstance(node: Instance): void {
// these fields are relevant.
delete (node: any)[internalInstanceKey];
delete (node: any)[internalPropsKey];
delete (node: any)[internalContainerInstanceKey];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was something we also cleared out in the previous v17 fix, however its not needed imo. This is only set for the container root node (which I think means the root of react's tree). since v17, you can have multiple roots so react can run multiple versions, but I think we only have one root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant