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 useMetadata leak #227

Merged
merged 1 commit into from
Sep 19, 2024
Merged

Fix useMetadata leak #227

merged 1 commit into from
Sep 19, 2024

Conversation

csansoon
Copy link
Contributor

Fixed memory leak from useMetadata hook.

Also improved performance by calculating metadata only once while the document loads, instead of 50+ times :)

Comment on lines -27 to +29
data = [],
data = EMPTY_ARRAY,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This guy was being was being set as a different "empty array" instance on every single render, and thus triggering anything that subscribed to it as a dependency. Thanks to this, opening a new document would compute the document's metadata 50+ times while this store was still loading its data.

@csansoon csansoon merged commit 9111db7 into main Sep 19, 2024
3 of 4 checks passed
@csansoon csansoon deleted the Fix-useMetadata-leak branch September 19, 2024 13:40
@github-actions github-actions bot locked and limited conversation to collaborators Sep 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants