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

batchedCallbacks memory leak in Chrome #85

Closed
AMStrix opened this issue May 21, 2019 · 4 comments
Closed

batchedCallbacks memory leak in Chrome #85

AMStrix opened this issue May 21, 2019 · 4 comments

Comments

@AMStrix
Copy link

AMStrix commented May 21, 2019

First, thanks for an excellent library!

Second, there appears to be a memory leak for batched functions in Chrome.

  • os: macOS 10.14.4
  • browser: Chrome 74.0.3729.157
  • react-easy-state@6.1.1
  • react@16.8.6

I noticed the heap growing linearly in my app as it polls for data from a rest api. I narrowed it down to the batched callbacks mechanism in scheduler.js using the chrome devtools/Memory profiler.

The memory gets released when the globalObj batched method assignments are removed from scheduler.js.

devtools/Memory/Allocation instrumentation timeline

Screen Shot 2019-05-21 at 10 56 35 AM

This behavior is also observable on the beer finder demo. With the Memory profiler - Allocation instrumentation on timeline running just repeatedly enter queries into the search.

beer finder

Screen Shot 2019-05-21 at 11 26 01 AM

@solkimicreb
Copy link
Member

Thanks for all the details! It feels good to see issues like this 🙂 I will look into this in a few hours.

@solkimicreb
Copy link
Member

This should definitely be a WeakMap: https://github.com/solkimicreb/react-easy-state/blob/master/src/scheduler.js#L18. I will check if I made some other obvious mistakes with the batching. 🤦‍♂

@solkimicreb
Copy link
Member

I just release a new patch (v6.1.2) which should fix this. Please reopen it if the issue is not fixed. Thanks for the nice detailed issue again 🙂

@AMStrix
Copy link
Author

AMStrix commented May 23, 2019

Upgraded, works great! Thanks for the quick turnaround on this.

Much appreciated and happy coding to you!

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

No branches or pull requests

2 participants