mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix memory leak in experiment: JNI leak
Summary: I think this array is copied when we call the function over the JNI, and that we need to free the local copy we make. Reviewed By: mdvacca Differential Revision: D17377077 fbshipit-source-id: 82fe4ec89e95335a329f4ce562441561dbe88693
This commit is contained in:
committed by
Facebook Github Bot
parent
87af32a24c
commit
4b59360a59
@@ -489,7 +489,16 @@ local_ref<JMountItem::javaobject> createRemoveAndDeleteMultiMountItem(
|
||||
jni::findClassStatic(UIManagerJavaDescriptor)
|
||||
->getMethod<alias_ref<JMountItem>(jintArray)>("removeDeleteMultiMountItem");
|
||||
|
||||
return removeDeleteMultiInstruction(javaUIManager, removeAndDeleteArray);
|
||||
auto ret = removeDeleteMultiInstruction(javaUIManager, removeAndDeleteArray);
|
||||
|
||||
// It is not strictly necessary to manually delete the ref here, in this particular case.
|
||||
// If JNI memory is being allocated in a loop, it's easy to overload the localref table
|
||||
// and crash; this is not possible in this case since the JNI would automatically clear this
|
||||
// ref when it goes out of scope, anyway. However, this is being left here as a reminder of
|
||||
// good hygiene and to be careful with JNI-allocated memory in general.
|
||||
env->DeleteLocalRef(removeAndDeleteArray);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// TODO T48019320: because we pass initial props and state to the Create (and preallocate) mount instruction,
|
||||
|
||||
Reference in New Issue
Block a user