Skip to content

ReactMount.nodeCache leaks objects during unmount #2731

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

Closed
1st1 opened this issue Dec 17, 2014 · 5 comments
Closed

ReactMount.nodeCache leaks objects during unmount #2731

1st1 opened this issue Dec 17, 2014 · 5 comments

Comments

@1st1
Copy link

1st1 commented Dec 17, 2014

The scenario for this is pretty easy to reproduce:

  1. Suppose we have a popup implementation -- there is a function to render popup view (react element) in an overlay div element, and a function to unmount the view and destroy the overlay.
  2. In that popup we have a button element, with its onClick set to call the destroy popup function.
  3. When a user clicks that button, React.unmountComponentAtNode is called, and react cleans everything up (ReactMount.nodeCache is empty), but then, react starts to process the blur event (remember, the user clicked the button to close the popup, so it was focused), and that resurrects the button element in ReactMount.nodeCache.
  4. The button DOM element ends up being stuck in nodeCache forever, but the worst part of it is that a lot of DOM nodes (sometimes hundreds) are not subject for GC anymore.
@syranide
Copy link
Contributor

@1st1 If you haven't "figured it out" yet, just defer the unmount and it should all be fine (until this is resolved one way or another).

@1st1
Copy link
Author

1st1 commented Dec 18, 2014

@syranide I simply "blur()" the button before closing the popup.

The issue though, should be fixed in react. It shouldn't process any events on elements being unmounted, left alone leaving them alive in any caches.

@1st1
Copy link
Author

1st1 commented Dec 18, 2014

I think this issue is related to #2605

@aweary
Copy link
Contributor

aweary commented Apr 25, 2016

@spicyj this should be closed since 4ba0e95 removed nodeCache, right?

@sophiebits
Copy link
Collaborator

Yeah, this should be fixed now. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants