-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix GC memory leak (2) #4513
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
packages/lexical/src/LexicalGC.ts
Outdated
const nodeMapDeleteLength = nodeMapDelete.length; | ||
for (let i = 0; i < nodeMapDeleteLength; i++) { | ||
nodeMap.delete(nodeMapDelete[i]); | ||
} |
There was a problem hiding this comment.
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 😎
There was a problem hiding this comment.
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)
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.