-
Notifications
You must be signed in to change notification settings - Fork 934
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
Big Memory Leak / Retained Memory #809
Comments
Could render it to the core of the issue.
Looking further into it. |
Hello @Fabbok1x, thank you for looking into this. What action are you taking to cause the table to unmount and remount? Your example just looks like a static version of the default table, so I'm unclear on the exact steps you're using. |
I'm loading some components dynamically like this: I may write a small codesandbox to illustrate the issue. I'm not yet exactly sure what causes this but the above snippet certainly has something to do with this, possibly also this line
in the same render function, a change to Additionally these binds in the TableBody Only thing I came to verify so far is the TableToolbar definetly playing a role in this. |
Came to verify the issue to some extend. So one thing that is safe to say is that something within styled.js is causing the RAM leak. Modding TableToolbar to not use the styled HOC will definetly resolve the leak. Didn't have enough time to dig into what's exactly causing this within styled, however disabling the HOC and removing the classes does seem to do a sufficent job for me at the moment. Result (after about 4 remounts): In case someone wants to have a look at styled:
In case you have an idea what could be causing the leak feel free to let us know, any help here would be greatly appreciated. |
It will be difficult for me to isolate without an example I can continually use to check the problem. If it's specific to dynamically loaded components, that seems far enough away from traditional use cases, that it might be hard to pin the problem entirely on this library. So I'd need either a reproducible example or something where it's an issue without the dynamic loading. |
I decided to take a look into this and I noticed a few things:
I've put in a PR that refactors TableToolbar to use withStyles instead of styled.js. I also added a warning if someone puts in an invalid value for options.responsive. Unless I'm missing something, that should hopefully clear up this memory issue. I've looked over TableToolbar several times and can't see any other reason styled.js was being used. |
I can confirm this memory leak. I was able to re-produce this in my work environment and have created a sandbox the simulates the problem: https://codesandbox.io/s/muidatatables-custom-toolbar-5o1hr Here's how to re-produce the issue:
For this small example it's not terrible (around 1.3MB like @Fabbok1x said), but for larger tables there's a lot of memory that doesn't appear to be being released (on my workstation I had a table that was 10MB). Edit: A more easily reproducible example is here: #829 (comment)
Also, as a use case for when this would happen: The use case for me is an interface that uses tabs. My app has a sidebar that has buttons that open up a tab with a datatable. A user interacts with the table and then closes the tab. |
Sorry for posting on this so much. I've updated the example in my previous comment to be more clear (ie, you need to select a particular VM or you won't see the memory leak). The example in my PR is a little more straight forward, but confusingly it requires the selection of a different VM - I'm guessing codesandbox sets up the VMs differently when you create a sandbox from a repo. You'll know you're watching the right VM if the memory spikes up to around 1.3MB when the table appears. |
Closing this, as the additions have been in the library for a few releases now. If there's good evidence that there's still an issue that is related to the things in discussion here, I can re-open. |
When unmounting, and mounting the MUIDataTable, using
https://codesandbox.io/embed/q8w3230qpj?autoresize=1&hidenavigation=1
about 1.3 mb of memory is not free'd. This is problematic despite one-page apps and multiple mounts and unmounts.
This image illustrates the issue:
https://i.imgur.com/zLAdUbi.png
This is a look at the FiberNodes:
https://i.imgur.com/UwZelkZ.png
Each peak is one mount (with a previous unmount).
tableRef seems to play a role in the memory retaining.
The text was updated successfully, but these errors were encountered: