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
merged 2 commits into from Nov 19, 2018

Conversation

Projects
None yet
4 participants
@trueadm
Copy link
Contributor

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;

This comment has been minimized.

@gaearon

gaearon Nov 19, 2018

Member

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

@sizebot

This comment has been minimized.

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

1 check passed

ci/circleci Your tests passed on CircleCI!
Details

@trueadm trueadm deleted the trueadm:null-out-memoizedState-and-updateQueue branch Nov 19, 2018

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