Commit bc766ec
fix memory leak in Android (#35889)
Summary:
fix memory leak in Android
The issues link: #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: #35889
Reviewed By: christophpurrer
Differential Revision: D42636805
Pulled By: sshic
fbshipit-source-id: 76845b5c1fbdeaf1ebe990356e82059dc1e5b46e1 parent 9eaf6f5 commit bc766ec
3 files changed
Lines changed: 25 additions & 9 deletions
File tree
- ReactAndroid/src/main/java/com/facebook/react/uimanager
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
666 | 666 | | |
667 | 667 | | |
668 | 668 | | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
669 | 678 | | |
670 | 679 | | |
671 | 680 | | |
| |||
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
173 | 182 | | |
174 | 183 | | |
175 | 184 | | |
| |||
599 | 608 | | |
600 | 609 | | |
601 | 610 | | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
602 | 617 | | |
603 | 618 | | |
604 | 619 | | |
| |||
Lines changed: 1 addition & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
117 | 116 | | |
118 | 117 | | |
119 | 118 | | |
| |||
403 | 402 | | |
404 | 403 | | |
405 | 404 | | |
406 | | - | |
407 | 405 | | |
408 | 406 | | |
409 | 407 | | |
| |||
427 | 425 | | |
428 | 426 | | |
429 | 427 | | |
430 | | - | |
431 | 428 | | |
432 | 429 | | |
433 | 430 | | |
| |||
768 | 765 | | |
769 | 766 | | |
770 | 767 | | |
771 | | - | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
776 | | - | |
| 768 | + | |
777 | 769 | | |
778 | 770 | | |
779 | 771 | | |
| |||
0 commit comments