Skip to content
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

Clear fields on unmount of fiber to avoid memory leak #14276

Merged

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Nov 19, 2018

This PR is a follow up to #14218. In that PR, fields that we were unsure about were nulled out. This changes the nulling out of fields to the two that we know are safe to null out – specifically, memoizedState and updateQueue. This stops the memory leak we encounter when the associated fibers containing the references to the closures (stored in memoizedState) still exist after being unmounted

const alternate = current.alternate;
if (alternate !== null) {
alternate.child = null;
alternate.return = null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: reorder to match the order above? So it's easier to see they're the same.

@sizebot
Copy link

sizebot commented Nov 19, 2018

ReactDOM: size: 🔺+0.1%, gzip: 🔺+0.1%

Details of bundled changes.

Comparing: d204747...2b9fe40

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js 0.0% 0.0% 716.11 KB 716.26 KB 165.75 KB 165.79 KB UMD_DEV
react-dom.production.min.js 🔺+0.1% 🔺+0.1% 97.66 KB 97.74 KB 31.8 KB 31.81 KB UMD_PROD
react-dom.profiling.min.js +0.1% -0.0% 100.56 KB 100.63 KB 32.5 KB 32.5 KB UMD_PROFILING
react-dom.development.js 0.0% 0.0% 711.42 KB 711.57 KB 164.38 KB 164.41 KB NODE_DEV
react-dom.production.min.js 🔺+0.1% 🔺+0.1% 97.65 KB 97.73 KB 31.31 KB 31.34 KB NODE_PROD
react-dom.profiling.min.js +0.1% 0.0% 100.65 KB 100.72 KB 31.93 KB 31.94 KB NODE_PROFILING
ReactDOM-dev.js 0.0% 0.0% 732.57 KB 732.72 KB 165.51 KB 165.54 KB FB_WWW_DEV
ReactDOM-prod.js 🔺+0.1% 0.0% 309.63 KB 309.95 KB 57.06 KB 57.07 KB FB_WWW_PROD
ReactDOM-profiling.js +0.1% 0.0% 316.53 KB 316.73 KB 58.46 KB 58.48 KB FB_WWW_PROFILING

Generated by 🚫 dangerJS

@trueadm trueadm merged commit 0e9cb3f into facebook:master Nov 19, 2018
@trueadm trueadm deleted the null-out-memoizedState-and-updateQueue branch November 19, 2018 16:09
jetoneza pushed a commit to jetoneza/react that referenced this pull request Jan 23, 2019
* Clear fields on unmount of fiber to avoid memory leak
n8schloss pushed a commit to n8schloss/react that referenced this pull request Jan 31, 2019
* Clear fields on unmount of fiber to avoid memory leak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants