-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Memory Leak in Dialog Management: ReactRootView not removed from View Tree when Dialog is not showing #45080
Comments
|
Can you provide a valid repro an a screenshot from the memory profiler of Android Studio? |
First, in my issue, I provided the memory leak path captured by LeakCanary. When looking at the code, this issue becomes very clear: Regardless of the state of the Dialog, To reproduce this issue is very simple. You just need to start by creating a Native @Override
public void hide() {
if (isShowing()) {
mDialog.dismiss();
}
if (mReactRootView != null && mReactRootView.getParent() != null) {
((ViewGroup) mReactRootView.getParent()).removeView(mReactRootView);
}
mDialog = null;
} |
Description
There is a memory leak in the dialog management code of React Native's new architecture. When the hide() method is called and the dialog is not currently showing, the ReactRootView is not removed from the view tree. This results in the ReactRootView holding a reference to the Activity, causing a memory leak.
Steps to reproduce
React Native Version
0.74.2
Affected Platforms
Runtime - Android
Areas
TurboModule - The New Native Module System
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/react-native-community/reproducer-react-native/tree/main
Screenshots and Videos
No response
The text was updated successfully, but these errors were encountered: