mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix ReactInstanceManager leak (#41719)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41719 We leak ReactInstanceManager into a static singleton in `ReactCxxErrorHandler.setHandleErrorFunc`. Clean it up in `destroy()`. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D51706624 fbshipit-source-id: 642825ba14ff0a9710b4435f5fb6026b3a81b711
This commit is contained in:
committed by
Facebook GitHub Bot
parent
424ac63861
commit
b41937e549
+9
-6
@@ -387,7 +387,7 @@ public class ReactInstanceManager {
|
||||
mDevSupportManager.handleException(e);
|
||||
}
|
||||
|
||||
public void registerCxxErrorHandlerFunc() {
|
||||
private void registerCxxErrorHandlerFunc() {
|
||||
Class[] parameterTypes = new Class[1];
|
||||
parameterTypes[0] = Exception.class;
|
||||
Method handleCxxErrorFunc = null;
|
||||
@@ -399,6 +399,10 @@ public class ReactInstanceManager {
|
||||
ReactCxxErrorHandler.setHandleErrorFunc(this, handleCxxErrorFunc);
|
||||
}
|
||||
|
||||
private void unregisterCxxErrorHandlerFunc() {
|
||||
ReactCxxErrorHandler.setHandleErrorFunc(null, null);
|
||||
}
|
||||
|
||||
static void initializeSoLoaderIfNecessary(Context applicationContext) {
|
||||
// Call SoLoader.initialize here, this is required for apps that does not use exopackage and
|
||||
// does not use SoLoader for loading other native code except from the one used by React Native
|
||||
@@ -747,23 +751,22 @@ public class ReactInstanceManager {
|
||||
}
|
||||
|
||||
moveToBeforeCreateLifecycleState();
|
||||
|
||||
if (mCreateReactContextThread != null) {
|
||||
mCreateReactContextThread = null;
|
||||
}
|
||||
|
||||
mMemoryPressureRouter.destroy(mApplicationContext);
|
||||
unregisterCxxErrorHandlerFunc();
|
||||
|
||||
mCreateReactContextThread = null;
|
||||
synchronized (mReactContextLock) {
|
||||
if (mCurrentReactContext != null) {
|
||||
mCurrentReactContext.destroy();
|
||||
mCurrentReactContext = null;
|
||||
}
|
||||
}
|
||||
|
||||
mHasStartedCreatingInitialContext = false;
|
||||
mCurrentActivity = null;
|
||||
|
||||
ResourceDrawableIdHelper.getInstance().clear();
|
||||
|
||||
mHasStartedDestroying = false;
|
||||
synchronized (mHasStartedDestroying) {
|
||||
mHasStartedDestroying.notifyAll();
|
||||
|
||||
Reference in New Issue
Block a user