-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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 with latest React Native Integrated App on v0.74.2 #45217
Comments
@cortinico can you please look into this issue. |
Facing the same issue |
We are facing the same issue since 0.73.0. do we have any solution to this? |
Can you try to update incrementally (first to 0.72 and then 0.73) and mention where you notice this regression? |
Facing this issue from 0.73 version. 72.x works fine |
Facing the same memory leak issue. @cortinico This issue has been mentioned many times previously also. Kindly check this issue on priority. It is affecting all our integrated apps currently. Previously raised issues: |
Here are some more finding from my side for the memory leak I used this repo rn-diff-purge repo for taking android folders and followed the steps mentioned here in https://reactnative.dev/docs/integration-with-existing-apps for integration Here's what I did in this repo - https://github.com/satheshrgs-rksv/memoryleakreproducer. Please use this as reproducer
Following are some of the methods i tried Method 1: Method 2: Method 3: Method 4: Findings:
|
The main thing which we need to figure out is why in the latest versions of react native with brownfield approach multiple leaks are seen |
Please see this comment from @fannnzhang @cortinico Since we are nearing the android deadline for android 14 support and since ours is an integrated app running on 0.71.1, upgrading to latest versions of React Native is a must for this update. Could you please help with this as soon as possible |
@cortinico Any update on this ? |
I meet the same issue when integrate react native to my Android App, |
I cant even run the build in android and badly need to support my app in Android 14 and upcoming Android 15. |
I faced issue Android memory leak in pure react-native (not integration app) when running foreground still not resolve serviceshttps://github.com//issues/45001 |
Same here |
We have a hybrid app where we in our ApplicationController we are: private fun initReactNative() {
SoLoader.init(this, false)
ApplicationLifecycleDispatcher.onApplicationCreate(this)
reactNativeHost.reactInstanceManager.createReactContextInBackground()
} but then use a class RNFeedbackActivity : ReactActivity() {
override fun getMainComponentName(): String {
return "AppFeedback"
}
companion object {
fun startActivity(context: Context) {
val intent = Intent(context, RNFeedbackActivity::class.java)
.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
context.startActivity(intent)
}
}
} we use that We see this memory leak come up when we go in/out of that activity |
@satheshrgs-rksv May I ask if you are using new arch? We are experiencing the same issue and we use new arch. |
@yzhe554 No, not using new arch |
@cortinico Any update on this? I believe the issue blocks many brownfield projects. |
Nope there are no updates here. Once we have updates, we'll post them.
At this stage, the best you folks can do is keep on investigating where the leak is. Also better reproducers would help (like simpler apps rather than https://github.com/callstack/react-native-brownfield) |
https://github.com/satheshrgs-rksv/memoryleakreproducer |
Hi - I'm also working on a brownfield app and this memory leak has also impacted my app since upgrading to React Native 0.73.1. In my case, the problem is so severe that my app got flagged by Google Play for reaching the I'd like to share my research results that hopefully can help those who are experiencing the problem. TL;DR Reverting this commit from the React Native source seems to resolve the memory leak issue but might have an impact on apps using I created a minimal brownfield project in order to investigate the issue. The app has only two screens/activities:
I tried two RN versions 0.72.17 and 0.75.3 and noticed some important things when entering and leaving the RN screen:
Then I investigated the code changes between 0.72.17 and 0.73.0 and I found this commit that seems very likely be the cause of the leak. While the purpose of the commit is to clean up the views in the screen's root view, it somehow prevents the cleanup process of native components inside the screen from happening. So I tried reverting the changes in the commit and could see that the cleanup process happened as expected, Since I don't understand the codebase well enough, it's hard for me to come up with a reasonable fix for the memory leak. While reverting the mentioned commit could resolve the issue, it would defeat the purpose of the commit. I hope my research results help the React Native team more easily figure out and fix this problem. Feel free to tell me if there is anything more I can help with and I'm happy to have further discussion on this topic. |
@tranhoangduong1994 Thank you! I can also verify the issue is gone after patching a revert. Update: I just profile this again with new arch, I can still see memory leaks but just less. |
my issue still remain when running foreground service -> clear the app -> open app again MainActivity still leak |
@cortinico Is #41678 related to this ? |
Description
Facing Memory Leak with React Native app integrated with existing native app.
I am currently on React Native 0.71.1 and tried to update to React Native 0.74.2.After upgrade facing memory leak. Memory usage keeps on increasing. With version 0.72 also there is no leak faced. But from version 0.73 facing memory leak.
Following this react native callstack brownfield architecture to load react native inside existing app as we have multiple entry points from native app to load react native in Fragment and also in Activity.
Steps to reproduce
https://github.com/callstack/react-native-brownfield
yarn install
React Native Version
0.74.2
Affected Platforms
Runtime - Android
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/satheshrgs-rksv/memoryleakreproducer
Screenshots and Videos
The text was updated successfully, but these errors were encountered: