Skip to content

[Android] memory leak in Android #35890

Closed
@feiyin0719

Description

@feiyin0719

Description

When we Integration RN as App SubActivity, if we close the Activity, it will cause memory leak

Explain Defect

since 0.65, when call dispatchViewUpdates, we add judge mNumRootViews>0
image
When we call removeRootView, it will decrease the mNumRootViews before dispatchViewUpdates
image
So when we remove the last rootview, it will skip call dispatchViewUpdates and do not remove it, it will cause memory leak

Version

0.65 - ~

Output of npx react-native info

N/A

Steps to reproduce

  1. Integrate RN as part Activity of APP(do not use RN as MainActivity)
  2. open RN Activity
  3. close RN Activity
    it will cause memory leak

Snack, code example, screenshot, or link to a repository

code example
https://github.com/feiyin0719/RNMemoryLeakAndroid

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Triage 🔍Platform: AndroidAndroid applications.StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions