-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Memory leak on component unmount #12102
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
Comments
Closed with #12105. Thanks also for putting up a fix! Sorry I missed it originally – it's quite rare for someone to put up an issue and link to the fix at the same time :) |
I am still experiencing this issue. Despite the element unmounting (navigating to a new page) it still seems to hold memory of an object used in an onclick function. In my case it's a very very large object so this is problematic. The onclick prop of my Button is from |
It's almost impossible to fix this without some form of reproduction. |
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
When a component is unmounted, event listeners which were attached to
document
on component mount are not removed. This leads to a memory leak as there are unused event listeners leftover after components unmount.This can be verified by using chrome devtools, and taking heap snapshots at various points throughout page navigation/components mounting and unmounting, where the number of event listeners increases over time. It can also be verified in elements -> event listeners tab in devtools, where there are an increasing number of listeners upon mounting and unmounting components.
Fix is here: #12101
I'm not sure if this is the correct way of reporting an issue (making a fix as well as issue ticket), but just wanted more visibility here. If not, feel free to close this one.
Reproduction
Call unmount() on a component, observe how document event listeners are still retained, number of event listeners in memory using chrome memory devtools will show increasing amount as components are unmounted
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: