react-native
react-native copied to clipboard
Memory leak at JavaModuleWrapper.mModuleHolder
I got a memory leak on the Android platform when I launch a ReactActivity and finish it.
Description
LeakCanary report a memory leak when i launch a ReactActivity and finish it subsequently.
React Native version:
react-native info
F:\AwesomeProject>yarn react-native info
yarn run v1.5.1
$ F:\AwesomeProject\node_modules\.bin\react-native info
info Fetching system and libraries information...
System:
OS: Windows 10 10.0.18362
CPU: (4) x64 Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
Memory: 6.43 GB / 15.89 GB
Binaries:
Node: 12.18.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.5.1 - ~\AppData\Roaming\npm\yarn.CMD
npm: 6.14.5 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
IDEs:
Android Studio: Version 3.6.0.0 AI-192.7142.36.36.6308749
Languages:
Java: 1.8.0_201 - C:\Program Files\Java\jdk1.8.0_201\bin\javac.EXE
Python: 3.8.3 - C:\Python38\python.EXE
npmPackages:
@react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.2 => 0.62.2
npmGlobalPackages:
*react-native*: Not Found
Done in 4.36s.
Steps To Reproduce
Provide a detailed list of steps that reproduce the issue.
- Create a AwesomeProject via
npx react-native init AwesomeProject
; - Create a new activity called LauncherActivity as the launcher activity of App, and activity's layout contains a button for click jump to MainActivity, of cause need delete the
MainActivity
'sintent-filter
inAndroidManifest.xml
; - Click LauncherActivity's button jump to MainActivity and then back to LauncherActivity and then back to system launcher, a memory leak occurs.
Expected Results
don't leak.
Snack, code example, screenshot, or link to a repository:
LauncherActivity.java
package com.awesomeproject;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
public class LauncherActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_launcher);
findViewById(R.id.button).setOnClickListener(v ->
startActivity(new Intent(this, MainActivity.class)));
}
}
activity_launcher.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".LauncherActivity">
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="jump to MainActivity" />
</LinearLayout>
MainActivity.java
package com.awesomeproject;
import androidx.annotation.Nullable;
import com.facebook.react.ReactActivity;
public class MainActivity extends ReactActivity {
@Nullable
@Override
protected String getMainComponentName() {
return "AwesomeProject";
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.awesomeproject">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme">
<activity
android:name=".LauncherActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:label="@string/app_name"
android:windowSoftInputMode="adjustResize" />
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.
how to fix the problem?
how to deal it?
how to deal it?
how to deal it?
Did anyone get solutions?
it still require the community's attention. Any news around fix?
how to fix the problem?
Still need to fix.. exists in latest version as well.
Just adding my Analysis : I just found when we start React native app after first time then it is trying to remove the re What I found react-native view keep activity ref in mTagsToViews and trying to remove reference of last time opened React activity when we opened it subsequently next time. Ideally it should be removed when we close the application last time itself.
Any updates? This is still an issue for me.
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.
Facing same issue