-
Notifications
You must be signed in to change notification settings - Fork 47.4k
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
Fix a memory leak in ReactComponentTreeDevtool #6753
Conversation
d912a94
to
427cb39
Compare
@@ -106,6 +106,11 @@ var ReactComponentTreeDevtool = { | |||
}, | |||
|
|||
purgeUnmountedComponents() { | |||
if (ReactComponentTreeDevtool._preventPurging) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big fan of these but I’m not sure how else we can test the expected tree during server rendering, if ReactDebugTool
cleans it up right before the batch. Alternatively we can make those integration tests instead in ReactPerf-test
, but I like how comprehensive the suite for ReactComponentDebugTool
is, so I don’t want to replicate the same complexity in ReactPerf-test
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add another devtool in the test that checks the state at an appropriate time? If not or if that's too clunky, I think this seems fine too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d keep it this way for now. I’m not sure about this reliance on flush events anyway (#6046 (comment)), so I’d rather avoid relying on the order in which devtools are called for now.
Thanks. |
`ReactDebugTool` used to only call `purgeUnmountedComponents()` while profiling, so information about unmounted instances kept accumulating when not profiling. Additionally, unmounting in React Native and rendering to string did not correctly clean up the devtool. Finally, the tests tested the wrong behavior and relied on explicit `purgeUnmountedComponent()` calls. To fix this, we: * Test specifically that unmounting is enough to clean up the tree devtool. * Add missing `onBeginFlush` and `onEndFlush` calls to server and native rendering so `ReactDebugTool` knows when to copy the tree. Fixes #6750
@gaearon updated the pull request. |
Fix a memory leak in ReactComponentTreeDevtool (cherry picked from commit de1bb7a)
ReactDebugTool
used to only callpurgeUnmountedComponents()
while profiling, so information about unmounted instances kept accumulating when not profiling.Additionally, unmounting in React Native and rendering to string did not correctly clean up the devtool.
Finally, the tests tested the wrong behavior and relied on explicit
purgeUnmountedComponent()
calls.To fix this, we:
onBeginFlush
andonEndFlush
calls to server and native rendering soReactDebugTool
knows when to copy the tree.Fixes #6750.
Reviewers: @sebmarkbage @spicyj.