-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Bug: Memory leak in react while focusing input elements #26069
Comments
Same here, it's even happening with plain js. It seems not related to React itself. |
@YagamiNewLight I think This issue has already been resolved within react 18 , however I 'm not sure if there's a workaround for this in previous versions |
@Elwazer007 @YagamiNewLight Not resolved with react 18. Steps To Reproduce:
and after that you can found large detached input element exist I cant sure its react bug or chrome bug. hope some one can help no one answer this, I create other issue #27289 for attention |
It's actually a bug of chromium, here is the reference: https://bugs.chromium.org/p/chromium/issues/detail?id=866872 And here's a trick regarding this issue: Creating another focused input with no data attached to it before removing your big focused input can min this memory leak issue. |
very thanks @YagamiNewLight. |
哈哈,都是Chinese,我们用中文交流吧,你去抖音搜索一下 “游离节点造成的内存泄露”。就明白解决办法了 |
Hi @YagamiNewLight can you add the solution you suggested here ? |
Hi @Elwazer007 And here's the trick: Back to React, things get more complicated, the issue becomes: As long as your inputs are group rendered by JSX, no matter which input you are currently focusing, deleting all inputs will just lead to every input's memory leak. But the trick above will still work. |
Based on this discussion there may be some that Chromium is retaining. It may also help to try the latest canary version of React; I believe there have been some improvements made that are not yet in a stable release. It would be helpful to know if that solves it. |
@sophiebits having the same issue in 18.2.0. I've tried In my case that leads to leaking the whole React subtree where input is located which gives huge leaks over time. Also I can't somehow fix it with workarounds mentioned above. Are there any other possible workarounds? |
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment! |
The issue is very much alive and problematic. It's unfortunate it doesn't get enough attention. Also would be nice to have some workaround in React itself. Currently I have to call @rickhanlonii can we tell the bot to avoid closing this forever? Feels weird to remind it every time that it's still a problem. |
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment! |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you! |
Thanks for the ping @gyzerok, I re-opened and tagged so I won't get closed by stalebot. |
I 've noticed that having an
input
element focused and unmounting its owner component doesn't actually free up this component from the js heap , I 've created this simple blnkr to demonstarate this which add a dummyX
to a ref inside a component that has an input elementReact version: 17.0.2
Steps To Reproduce
Grow button
a few timesX
will be found within the `concat check the screenshotLink to code example: can be found above
The current behavior
The current component that own the input element is still being there in the memory and doesn't free up its own resources afer being unmounted.
The expected behavior
The current component shloud free up its resources whenever being unmounted
The text was updated successfully, but these errors were encountered: