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

Fix GC memory leak (2) #4513

Merged
merged 3 commits into from
May 19, 2023
Merged

Fix GC memory leak (2) #4513

merged 3 commits into from
May 19, 2023

Conversation

zurfyx
Copy link
Member

@zurfyx zurfyx commented May 17, 2023

The hardcoded condition on the test (const node = $getNodeByKey('1');) was hiding that the fix in #4510 was actually not good enough.

Subtrees fail. For example, if a subtree is deleted and we visit the parent later, their children might not have deleted (previously deleted)

This PR stores the dirtyElements keys to delete and does the deletion later, without interfering with the loop itself.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 17, 2023
@vercel
Copy link

vercel bot commented May 17, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 19, 2023 3:11pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 19, 2023 3:11pm

@github-actions
Copy link

github-actions bot commented May 17, 2023

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
packages/lexical/dist/Lexical.js 27.25 KB (0%) 546 ms (0%) 78 ms (+43.61% 🔺) 623 ms
packages/lexical-rich-text/dist/LexicalRichText.js 38.2 KB (0%) 765 ms (0%) 89 ms (-14.72% 🔽) 853 ms
packages/lexical-plain-text/dist/LexicalPlainText.js 38.18 KB (0%) 764 ms (0%) 104 ms (+22.19% 🔺) 867 ms

Comment on lines 112 to 115
const nodeMapDeleteLength = nodeMapDelete.length;
for (let i = 0; i < nodeMapDeleteLength; i++) {
nodeMap.delete(nodeMapDelete[i]);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC, for .. of is cooler 😎

Copy link
Member Author

Choose a reason for hiding this comment

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

@fantactuka - Is it also faster for arrays? afaik we started using for..of as a replacement for Array.from(<iterable = Set|Map)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants