Add registerNativeAllocation and registerNativeFree to libcore.
Required for ART native allocation accounting code.
(cherry picked from commit 71c68c5920a3be2f953624365da7cf0681fa32ed)
Change-Id: I5d5a4c908b3759a56e7e919754bbc26fcd051600
diff --git a/libart/src/main/java/dalvik/system/VMRuntime.java b/libart/src/main/java/dalvik/system/VMRuntime.java
index 85ca6af..fbfd8f6 100644
--- a/libart/src/main/java/dalvik/system/VMRuntime.java
+++ b/libart/src/main/java/dalvik/system/VMRuntime.java
@@ -223,6 +223,21 @@
*/
public native boolean isDebuggerActive();
+ /**
+ * Registers a native allocation so that the heap knows about it and performs GC as required.
+ * If the number of native allocated bytes exceeds the native allocation watermark, the
+ * function requests a concurrent GC. If the native bytes allocated exceeds a second higher
+ * watermark, it is determined that the application is registering native allocations at an
+ * unusually high rate and a GC is performed inside of the function to prevent memory usage
+ * from excessively increasing.
+ */
+ public native void registerNativeAllocation(int bytes);
+
+ /**
+ * Registers a native free by reducing the number of native bytes accounted for.
+ */
+ public native void registerNativeFree(int bytes);
+
/*
* Updates the internal process state of the VM. You can find the process states in
* ActivityManager.