-
Notifications
You must be signed in to change notification settings - Fork 116
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 solid memory leak #2738
Fix solid memory leak #2738
Conversation
🦋 Changeset detectedLatest commit: 29a7083 The changes in this PR will be included in the next version bump. This PR includes changesets to release 29 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
see comment.
@@ -339,6 +344,7 @@ async function loadMessagesViaPlugin( | |||
messages.set(loadedMessageClone.id, loadedMessageClone) | |||
// NOTE could use hash instead of the whole object JSON to save memory... | |||
messageState.messageLoadHash[loadedMessageClone.id] = importedEnecoded | |||
loadedMessageCount++ |
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.
Bumping the count in 2 different code paths and testing for loadedMessageCount % messagesPerTick === 0
later, makes the code a bit fragile. E.g. what if 2 bumps happen and you miss the % x === 0.
In cases like this I think it's less fragile to test for > maxMessagesPerTick and then reset the count.
// move loading of the next messages to the next ticks to allow solid to cleanup resources | ||
// solid needs some time to settle and clean up | ||
// https://github.com/solidjs-community/solid-primitives/blob/9ca76a47ffa2172770e075a90695cf933da0ff48/packages/trigger/src/index.ts#L64 | ||
await 0 |
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.
I think I'd prefer to use a setTimeout here. It's what we use for sleep in other places in the code like here
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.
I verified that the behavior of sleep(0) with setTimeout(...,0)
is not the same as await 0
Closing this PR - code is included in #2734 |
This change schedules message loading to the next tick on every 500th message to give solid a tick to free resources.
https://github.com/solidjs-community/solid-primitives/blob/9ca76a47ffa2172770e075a90695cf933da0ff48/packages/trigger/src/index.ts#L64