Skip to content

Fix fiber memory leak with runAllPassiveEffectDestroysBeforeCreates #18554

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

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Apr 9, 2020

This PR should fix the memory leak we saw internally when the runAllPassiveEffectDestroysBeforeCreates was enabled. I tested this both on our tests and also on our internal website and tests (with my deletion array collection approach) and can confirm the issue did not come up with that approach so I'm pretty confident that this particular memory leak is resolved.

The approach I took was to re-include the while loop that we had from before (but was in the old code path that gets executed without this flag). This time we only apply the nextEffect = null logic, excluding the execution of passive effects, and we get the result I described above.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 9, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 12923bf:

Sandbox Source
romantic-curran-0tzo3 Configuration

@sizebot
Copy link

sizebot commented Apr 9, 2020

Details of bundled changes.

Comparing: 8cbce05...12923bf

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactTestRenderer-dev.js +0.1% +0.1% 576.05 KB 576.5 KB 121.52 KB 121.63 KB FB_WWW_DEV
react-test-renderer-shallow.development.js 0.0% -0.0% 38.72 KB 38.72 KB 9.42 KB 9.42 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% -0.0% 12.74 KB 12.74 KB 3.97 KB 3.97 KB UMD_PROD
react-test-renderer.development.js -0.0% 0.0% 568.64 KB 568.62 KB 118.29 KB 118.29 KB UMD_DEV
react-test-renderer.production.min.js 0.0% 0.0% 74.16 KB 74.16 KB 22.54 KB 22.54 KB UMD_PROD
react-test-renderer.development.js -0.0% -0.0% 542.22 KB 542.2 KB 116.94 KB 116.94 KB NODE_DEV
react-test-renderer.production.min.js 0.0% 0.0% 73.96 KB 73.96 KB 22.25 KB 22.25 KB NODE_PROD

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom-server.browser.production.min.js 0.0% 0.0% 23.39 KB 23.39 KB 8.6 KB 8.6 KB UMD_PROD
react-dom.profiling.min.js 0.0% 0.0% 127.78 KB 127.78 KB 39.88 KB 39.88 KB NODE_PROFILING
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 4.91 KB 4.91 KB 1.64 KB 1.64 KB UMD_DEV
ReactDOM-dev.js +0.1% +0.1% 979.88 KB 980.39 KB 217.26 KB 217.38 KB FB_WWW_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.1% 1.2 KB 1.2 KB 704 B 705 B UMD_PROD
ReactDOM-prod.js 0.0% 🔺+0.1% 408.63 KB 408.82 KB 73.95 KB 73.99 KB FB_WWW_PROD
ReactDOM-profiling.js +0.1% +0.1% 419.47 KB 419.73 KB 75.79 KB 75.83 KB FB_WWW_PROFILING
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 4.43 KB 4.43 KB 1.54 KB 1.55 KB NODE_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.2% 1.02 KB 1.02 KB 616 B 617 B NODE_PROD
react-dom-test-utils.development.js 0.0% 0.0% 75.14 KB 75.14 KB 20.11 KB 20.11 KB UMD_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 13.23 KB 13.23 KB 4.9 KB 4.9 KB UMD_PROD
ReactDOMTesting-dev.js +0.1% +0.1% 930.24 KB 930.74 KB 207.26 KB 207.37 KB FB_WWW_DEV
ReactDOMTesting-prod.js 0.0% 🔺+0.1% 393.25 KB 393.45 KB 71.67 KB 71.71 KB FB_WWW_PROD
react-dom-test-utils.development.js 0.0% 0.0% 69.98 KB 69.98 KB 19.61 KB 19.61 KB NODE_DEV
ReactDOMTesting-profiling.js 0.0% +0.1% 393.25 KB 393.45 KB 71.67 KB 71.71 KB FB_WWW_PROFILING
react-dom-server.node.development.js 0.0% 0.0% 148.58 KB 148.58 KB 39.1 KB 39.1 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 13.1 KB 13.1 KB 4.81 KB 4.81 KB NODE_PROD
react-dom-server.node.production.min.js 0.0% 0.0% 23.69 KB 23.69 KB 8.72 KB 8.72 KB NODE_PROD
react-dom.development.js -0.0% 0.0% 935.9 KB 935.89 KB 204.13 KB 204.13 KB UMD_DEV
react-dom.production.min.js 0.0% 0.0% 123.6 KB 123.6 KB 39.39 KB 39.4 KB UMD_PROD
ReactDOMForked-dev.js +0.1% +0.1% 980.97 KB 981.48 KB 217.32 KB 217.44 KB FB_WWW_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 10 KB 10 KB 3.36 KB 3.36 KB UMD_PROD
ReactDOMServer-dev.js 0.0% -0.0% 154.48 KB 154.48 KB 38.97 KB 38.97 KB FB_WWW_DEV
react-dom.profiling.min.js 0.0% 0.0% 127.45 KB 127.45 KB 40.62 KB 40.62 KB UMD_PROFILING
ReactDOMForked-prod.js 0.0% 🔺+0.1% 408.83 KB 409.02 KB 73.96 KB 74.01 KB FB_WWW_PROD
ReactDOMServer-prod.js 0.0% 0.0% 52.56 KB 52.56 KB 12.68 KB 12.68 KB FB_WWW_PROD
react-dom.development.js -0.0% -0.0% 891.15 KB 891.13 KB 201.67 KB 201.67 KB NODE_DEV
ReactDOMForked-profiling.js +0.1% +0.1% 419.67 KB 419.92 KB 75.8 KB 75.85 KB FB_WWW_PROFILING
react-dom-unstable-fizz.node.development.js 0.0% +0.1% 5.18 KB 5.18 KB 1.7 KB 1.7 KB NODE_DEV
react-dom.production.min.js 0.0% 0.0% 123.78 KB 123.78 KB 38.61 KB 38.61 KB NODE_PROD
react-dom-unstable-native-dependencies.production.min.js 0.0% 🔺+0.1% 9.75 KB 9.75 KB 3.25 KB 3.25 KB NODE_PROD
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.2% 1.17 KB 1.17 KB 666 B 667 B NODE_PROD

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js -0.0% -0.0% 653.22 KB 653.2 KB 137.09 KB 137.09 KB UMD_DEV
react-art.production.min.js 0.0% 0.0% 109.73 KB 109.73 KB 33.11 KB 33.11 KB UMD_PROD
react-art.development.js -0.0% 0.0% 556.79 KB 556.78 KB 119.56 KB 119.56 KB NODE_DEV
react-art.production.min.js 0.0% 0.0% 74.66 KB 74.66 KB 22.32 KB 22.32 KB NODE_PROD
ReactART-dev.js +0.1% +0.1% 588.95 KB 589.46 KB 123.59 KB 123.71 KB FB_WWW_DEV
ReactART-prod.js 🔺+0.1% 🔺+0.1% 240.79 KB 240.98 KB 40.69 KB 40.73 KB FB_WWW_PROD

ReactDOM: size: 0.0%, gzip: 0.0%

Size changes (experimental)

Generated by 🚫 dangerJS against 12923bf

@sizebot
Copy link

sizebot commented Apr 9, 2020

Details of bundled changes.

Comparing: 8cbce05...12923bf

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.production.min.js 0.0% 0.0% 119.64 KB 119.64 KB 37.5 KB 37.5 KB NODE_PROD
react-dom-test-utils.development.js 0.0% 0.0% 75.12 KB 75.12 KB 20.1 KB 20.11 KB UMD_DEV
ReactDOMTesting-profiling.js 0.0% +0.1% 405.08 KB 405.27 KB 73.46 KB 73.5 KB FB_WWW_PROFILING
react-dom-server.browser.production.min.js 0.0% 0.0% 22.82 KB 22.82 KB 8.48 KB 8.48 KB NODE_PROD
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 4.9 KB 4.9 KB 1.63 KB 1.64 KB UMD_DEV
react-dom.profiling.min.js 0.0% 0.0% 123.51 KB 123.51 KB 38.67 KB 38.67 KB NODE_PROFILING
react-dom-test-utils.production.min.js 0.0% 0.0% 13.22 KB 13.22 KB 4.89 KB 4.89 KB UMD_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.1% 1.19 KB 1.19 KB 696 B 697 B UMD_PROD
react-dom-server.node.development.js 0.0% 0.0% 147.06 KB 147.06 KB 38.88 KB 38.88 KB NODE_DEV
react-dom-server.node.production.min.js 0.0% 0.0% 23.23 KB 23.23 KB 8.65 KB 8.65 KB NODE_PROD
ReactDOMForked-dev.js +0.1% +0.1% 1008.85 KB 1009.36 KB 223.31 KB 223.42 KB FB_WWW_DEV
ReactDOMForked-prod.js 0.0% 🔺+0.1% 421.74 KB 421.93 KB 75.86 KB 75.89 KB FB_WWW_PROD
react-dom-unstable-fizz.node.development.js 0.0% +0.1% 5.16 KB 5.16 KB 1.69 KB 1.69 KB NODE_DEV
react-dom.development.js -0.0% 0.0% 905.98 KB 905.96 KB 198.86 KB 198.86 KB UMD_DEV
ReactDOMForked-profiling.js +0.1% +0.1% 432.64 KB 432.89 KB 77.74 KB 77.79 KB FB_WWW_PROFILING
react-dom.production.min.js 0.0% 0.0% 119.52 KB 119.52 KB 38.24 KB 38.24 KB UMD_PROD
react-dom-server.browser.production.min.js 0.0% 0.0% 22.92 KB 22.92 KB 8.51 KB 8.51 KB UMD_PROD
react-dom.profiling.min.js 0.0% 0.0% 123.26 KB 123.26 KB 39.47 KB 39.47 KB UMD_PROFILING
ReactDOMTesting-dev.js +0.1% 0.0% 956.79 KB 957.28 KB 212.9 KB 213 KB FB_WWW_DEV
react-dom.development.js -0.0% 0.0% 862.47 KB 862.46 KB 196.41 KB 196.41 KB NODE_DEV
ReactDOMTesting-prod.js 0.0% 🔺+0.1% 405.08 KB 405.27 KB 73.46 KB 73.5 KB FB_WWW_PROD
react-dom-server.browser.development.js 0.0% 0.0% 145.85 KB 145.85 KB 38.63 KB 38.63 KB NODE_DEV
ReactDOM-dev.js +0.1% +0.1% 1007.76 KB 1008.27 KB 223.25 KB 223.36 KB FB_WWW_DEV
ReactDOM-prod.js 0.0% 🔺+0.1% 421.54 KB 421.73 KB 75.83 KB 75.87 KB FB_WWW_PROD
react-dom-test-utils.development.js 0.0% 0.0% 69.97 KB 69.97 KB 19.6 KB 19.6 KB NODE_DEV
ReactDOMServer-prod.js 0.0% 0.0% 53.29 KB 53.29 KB 12.84 KB 12.84 KB FB_WWW_PROD
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 4.42 KB 4.42 KB 1.54 KB 1.54 KB NODE_DEV
ReactDOM-profiling.js +0.1% +0.1% 432.44 KB 432.7 KB 77.72 KB 77.77 KB FB_WWW_PROFILING
react-dom-test-utils.production.min.js 0.0% 0.0% 13.09 KB 13.09 KB 4.8 KB 4.8 KB NODE_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.3% 1 KB 1 KB 608 B 610 B NODE_PROD
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 9.98 KB 9.98 KB 3.35 KB 3.35 KB UMD_PROD
react-dom-unstable-native-dependencies.production.min.js 0.0% 🔺+0.1% 9.73 KB 9.73 KB 3.24 KB 3.25 KB NODE_PROD

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js -0.0% -0.0% 632.85 KB 632.83 KB 133.39 KB 133.38 KB UMD_DEV
react-art.production.min.js 0.0% 0.0% 107.12 KB 107.12 KB 32.44 KB 32.44 KB UMD_PROD
react-art.development.js -0.0% -0.0% 537.23 KB 537.22 KB 115.83 KB 115.82 KB NODE_DEV
react-art.production.min.js 0.0% 0.0% 72.11 KB 72.11 KB 21.66 KB 21.66 KB NODE_PROD
ReactART-dev.js +0.1% +0.1% 599.02 KB 599.53 KB 125.58 KB 125.69 KB FB_WWW_DEV
ReactART-prod.js 🔺+0.1% 🔺+0.1% 248.24 KB 248.43 KB 41.97 KB 42.01 KB FB_WWW_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer.development.js -0.0% 0.0% 568.61 KB 568.6 KB 118.28 KB 118.28 KB UMD_DEV
react-test-renderer.production.min.js 0.0% 0.0% 74.13 KB 74.13 KB 22.52 KB 22.52 KB UMD_PROD
react-test-renderer-shallow.development.js 0.0% -0.0% 38.71 KB 38.71 KB 9.42 KB 9.42 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% -0.0% 12.73 KB 12.73 KB 3.96 KB 3.96 KB UMD_PROD
react-test-renderer.development.js -0.0% -0.0% 542.19 KB 542.17 KB 116.93 KB 116.93 KB NODE_DEV
react-test-renderer.production.min.js 0.0% 0.0% 73.93 KB 73.93 KB 22.23 KB 22.23 KB NODE_PROD
ReactTestRenderer-dev.js +0.1% +0.1% 576.04 KB 576.49 KB 121.51 KB 121.63 KB FB_WWW_DEV

ReactDOM: size: 0.0%, gzip: 0.0%

Size changes (stable)

Generated by 🚫 dangerJS against 12923bf

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Apr 9, 2020
@trueadm trueadm merged commit 0566b70 into facebook:master Apr 9, 2020
@trueadm trueadm deleted the mem-leak-runAllPassiveEffectDestroysBeforeCreates branch April 9, 2020 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants