Comments (3)
Missing Reproducible Example | |
---|---|
ℹ️ | We could not detect a reproducible example in your issue report. Please provide either:
|
from react-native.
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.
Can you provide a valid repro an a screenshot from the memory profiler of Android Studio?
from react-native.
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, mReactRootView
will always be indirectly created and held by LogModule
, and when ReactRootView
is created, it holds a reference to the Activity
. Therefore, the hide
method of LogBoxDialogSurfaceDelegate
must ensure that it is removed from the Activity
. However, the current implementation of the hide
method does not do this. When the dialog is not created or shown, it directly returns, causing the view to not release the Activity
reference, which leads to a memory leak.
To reproduce this issue is very simple. You just need to start by creating a Native Activity
in the React Native Android template project, then navigate to a ReactActivity
, and finally return to the main Activity
from the ReactActivity
. This will reliably reproduce the memory leak. Additionally, this reproduction path may also uncover other memory leaks under the new architecture. I suggest conducting similar tests as soon as possible and fixing the related issues.
My local fix code like this:
@Override
public void hide() {
if (isShowing()) {
mDialog.dismiss();
}
if (mReactRootView != null && mReactRootView.getParent() != null) {
((ViewGroup) mReactRootView.getParent()).removeView(mReactRootView);
}
mDialog = null;
}
from react-native.
Related Issues (20)
- [android] Plugin [id: 'com.facebook.react.settings'] was not found in any of the following sources HOT 23
- Minimum supported Gradle version is 8.7. Current version is 8.6. RN 0.74.3 HOT 27
- [Android] Emiting Events from HeadlessTask on Android in New Arch + Bridgeless + interop layer HOT 2
- Flatten margin styles are not properly overriding when applied from specific to general properties HOT 8
- Cannot build project after a clean setup without expo HOT 11
- Unable to use react-native SDK ( .aar created from react-native app) in other react-native applications HOT 2
- Error with GeneratePackageListTask when build for Android HOT 28
- StatusBar Area Turns Black When Hidden Instead of Inheriting Background Color HOT 16
- Cannot inherit from final 'com.facebook.react.views.imagehelper.ImageSource' HOT 7
- App does not run at all in Android for React Native Version 75.1 or React Native 74.3 HOT 10
- Facing Maximum call stack size exceeded (native stack depth), stack while upgrading react-native from 0.64.2 to 0.74.0 HOT 6
- App Crashes - On upgrading to Android 14(SDK 34) HOT 2
- Touchable is unresponsive during internal ScrollView scroll on iOS
- npx @react-native-community/cli@latest init MyProject –-version latest, I got latest is not a valid version. HOT 8
- [iOS] Italic does not work in Text HOT 4
- GIF images not working after upgrade from React-Native 0.74.3 -> 0.75.1 HOT 5
- React Native: value attribute exists in 0.72 but not in 0.73 HOT 4
- [iOS] `accessibilityElementsHidden` does not work if the parent view is `accessible`
- Some of us hate kotlin, give us java back. HOT 5
- iOS: RCTImageLoader is documented to be thread safe but the setUp code has a race HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native.