-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[Datagrid] Possibly Memory Leak #6566
Comments
Hey @alexmarmon I can confirm there's a memory leak. |
@cherniavskii Thank you for taking a look, really appreciate you jumping in so quickly! 🙏 How long does it typically take for a fix to be merged and deployed? |
@alexmarmon what would be the workaround before the fix is released? Is there a stable version you can recommend using before the fix is released? |
@alexmarmon the fix should be included in this week's release on Thursday |
@cherniavskii Amazing. thank you! |
@alexmarmon Thanks for reporting the issue! |
I have tested version 6.0.2 and I believe there is still a bug with the recent bugfix. The problem is that This may be related to React Strict Mode. From the React documentation:
It's possible that React is reusing the Ref object, and by the time the cleanup hook gets called, apiRef.current has already changed. |
@zroug |
Sure, but when the cache is not cleaned for all cache keys, that means the memory leak still exists. |
@zroug This statement explains it well:
Here's a production deployment of the demo I've linked above: https://csb-3riivj-hpx7jnjbt-cherniavskii.vercel.app/ Do you experience any specific issues with this approach in development? |
Thank you for providing the example, it does show the problem very well. While it may not be a significant concern if this happens only during development, it could be beneficial to document this behavior. This is because memory leaks like this (especially if they happen in foreign code) can be challenging to debug and may arise during testing in development mode. Alternatively, addressing the issue permanently could prevent confusion and would avoid this improper usage of React APIs. Currently, |
Thanks for the context, I find this very convincing! I looked into it and I think we can indeed leverage |
Duplicates
Latest version
Current behavior 😯
When navigating to and from a page that mounts Datagrid with a large dataset, the total JS heap size grows in size continuously.
Expected behavior 🤔
Spikes of the JS heap size are expected during render/mount, but once the Datagrid is unmounted, allocated memory should be garbage collected.
Steps to reproduce 🕹
Link to live example: https://stackblitz.com/edit/datagrid-pro-memory-issue
Steps:
Example screenshots:
Load #1 - https://drive.google.com/file/d/1Wa-GEeVBZz-aYYakCfC6oQ6oWbosKwkX/view?usp=sharing
Load #2 - https://drive.google.com/file/d/1BFfDUGHt2scTmVHnqaQ_e-SeXq0JL4v9/view?usp=sharing
Load #3 - https://drive.google.com/file/d/17yu7vklO_-klD0So5Wm2OHViP5idXQ9r/view?usp=sharing
Load #4 - https://drive.google.com/file/d/1DusjWBpLSniFhCVDlQxkw_l6xfgVWTeL/view?usp=sharing
Comparison Steps:
Example Alt screenshots:
Load #1 - https://drive.google.com/file/d/1Y7E_O46EIzyJhS3mn16yYcwNb6dNhADO/view?usp=sharing
Load #2 - https://drive.google.com/file/d/1dqMSTig0q1iFoR4JWI2FM_LreaBI35xn/view?usp=sharing
Load #3 - https://drive.google.com/file/d/1X4hsI72htZFWmLM0nuLEhpMK9bHhOpwY/view?usp=sharing
Load #4 - https://drive.google.com/file/d/12iX3RTzqd7eEyZASqqIRztgEfTK52oyq/view?usp=sharing
Context 🔦
We have an unfortunately large dataset being loaded into the browser for our larger customers. Refactoring the entire stack to not expect all data to be available at all times is a long term goal but fixing this leak will be a massive win in the short term. In some cases we've observed our customer's heap size in excess of 1gb.
Your environment 🌎
Chrome
Please see Stackblitz for versions being used, should be latest in all cases.
Order ID 💳 (optional)
37236
The text was updated successfully, but these errors were encountered: