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 memory leak #163

Merged
merged 1 commit into from
Jun 10, 2022
Merged

Fix memory leak #163

merged 1 commit into from
Jun 10, 2022

Conversation

namoscato
Copy link
Contributor

Fixes #160

I noticed the #160 memory leak issue as well (i.e. it's reproducible in the simple example), but it was unfortunately not fixed with #161.

This makes two changes, which seems to mitigate the issue:

  1. Update the setTimeout callback to just bump a (new) timeNow state. I think passing a reference to the tick function was ultimately causing the memory leak, and this approach also removes the need for a "force update".
  2. Update the default now argument to a Date.now reference (as opposed to a new closure). This was getting redefined on every render and causing duplicate effect calls, which was contributing to the issue.

@nmn nmn merged commit 0d7c0f9 into nmn:master Jun 10, 2022
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.

Memory leak
2 participants