mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-27 22:54:46 +08:00
Add finalizer to release any unreleased native memory
Reviewed By: lucasr Differential Revision: D3992759 fbshipit-source-id: f648b72ead5bdb7257a5197496b19795f71f3788
This commit is contained in:
committed by
Facebook Github Bot
parent
a5698f5cea
commit
08e715bc9c
@@ -60,6 +60,10 @@ public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
|
||||
throw new IllegalStateException("You should not reset an attached CSSNode");
|
||||
}
|
||||
|
||||
free();
|
||||
}
|
||||
|
||||
private void free() {
|
||||
jni_CSSNodeFree(mNativePointer);
|
||||
mNativePointer = 0;
|
||||
mChildren = null;
|
||||
@@ -67,6 +71,17 @@ public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
|
||||
mMeasureFunction = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
if (mNativePointer != 0) {
|
||||
free();
|
||||
}
|
||||
} finally {
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChildCount() {
|
||||
return mChildren.size();
|
||||
|
||||
Reference in New Issue
Block a user