This issue is a summary of issues mentioned in https://github.com/facebook/react/pull/15157.
There are many different ways to create memory leaks with React since we give you access to the imperative power to do so. Most should be dealt with by clean up / unmount functions.
Some could be pure React bugs. Some could be related to the lack of clean up of render phase effects. Others could be related to leaks that exists but the way React works makes them larger than they otherwise would've.
I think there are at least two actionable patterns to address from #15157:
@matthewbryancurtis You are using CodeSandbox which runs React in development mode and includes a ton of other code. Can you please create a React-only demo in production mode? Thanks.
If GC cleans it up, then it's not a memory leak, is it?
Sorry, my misunderstanding. I'll go ahead and delete my comments to reduce noise on this issue.
Regarding
If a handle on a DOM node is leaked, it takes the React tree with it ... What we would do here is special case DOM nodes with refs on them, and always detach their back pointer to the React Fiber, if it was ever fully mounted
In #17581 I suggest that most if not all input nodes are retained by the browser; in which case React might want to detach fibers from all input nodes as well, not just nodes with refs. These leaks are occurring automatically and are not necessarily caused by developer error.
Do we think this should be prioritized? I'd be happy to contribute, though I'm not familiar at all with the unmounting/cleanup cycle and would appreciate some guidance 馃檱
@albertxing I think I'm seeing the same memory leak issue as you here. I have DOM input nodes being held by Chrome seemingly indefinitely after they're unmounted, and those are retaining huge amounts of memory via memoizedProps etc. It's causing me some big problems. Did you make any progress on this?
Is there an estimate for when #18814 or other workarounds to the leaked-DOM-leaking-React trees issue will be picked back up?
I'm also hitting the issue where DOM nodes are retained in Chrome, but I haven't been able to track down exactly why
Most helpful comment
Is there an estimate for when #18814 or other workarounds to the leaked-DOM-leaking-React trees issue will be picked back up?
I'm also hitting the issue where DOM nodes are retained in Chrome, but I haven't been able to track down exactly why