Files
react-native/ReactAndroid
yinfei bc766ec7f8 fix memory leak in Android (#35889)
Summary:
fix memory leak in Android
The issues link: https://github.com/facebook/react-native/issues/35890
Explain Defect
since 0.65, when call dispatchViewUpdates, we add judge mNumRootViews>0
<img width="531" alt="image" src="https://user-images.githubusercontent.com/20136688/213394240-4c284df4-27de-494e-8eed-8e5f30796cce.png">
When we call removeRootView, it will decrease the mNumRootViews before dispatchViewUpdates
<img width="430" alt="image" src="https://user-images.githubusercontent.com/20136688/213394611-d47ab49f-fc7a-4dd1-9836-fe667d655660.png">
So when we remove the last rootview, it will skip call dispatchViewUpdates and do not remove it, it will cause memory leak
Explain Fix
We should use the original root view num to judge, we can get it from NativeViewHierarchyManager

## Changelog
[ANDROID] [FIXED] - fix memory leak in Android
<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

Pull Request resolved: https://github.com/facebook/react-native/pull/35889

Reviewed By: christophpurrer

Differential Revision: D42636805

Pulled By: sshic

fbshipit-source-id: 76845b5c1fbdeaf1ebe990356e82059dc1e5b46e
2023-02-08 13:35:48 -08:00
..
2023-02-08 13:35:48 -08:00

Building React Native for Android

See the Building from Source guide on the React Native website.

Running tests

When you submit a pull request CircleCI will automatically run all tests. To run tests locally, see Testing guide on the React Native website.