summaryrefslogtreecommitdiff
path: root/src/dalvik_system_VMRuntime.cc
diff options
context:
space:
mode:
author Elliott Hughes <enh@google.com> 2012-02-02 17:08:25 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2012-02-02 17:08:25 -0800
commit054f6c19573100b29ce4139822bb496ba3d8e4d0 (patch)
tree145606aa94fd2e8c8882d6f29387649229ba8972 /src/dalvik_system_VMRuntime.cc
parent1ff1b98327b8056e20cd959963d759697a2b2f11 (diff)
parent8cf5bc0ab8742df107f0f4fc8ec0e991b6568f11 (diff)
Merge "Simple heap trimming." into dalvik-dev
Diffstat (limited to 'src/dalvik_system_VMRuntime.cc')
-rw-r--r--src/dalvik_system_VMRuntime.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/dalvik_system_VMRuntime.cc b/src/dalvik_system_VMRuntime.cc
index 76da622203..feb7749b1f 100644
--- a/src/dalvik_system_VMRuntime.cc
+++ b/src/dalvik_system_VMRuntime.cc
@@ -19,7 +19,9 @@
#include "jni_internal.h"
#include "object.h"
#include "object_utils.h"
+#include "space.h"
#include "thread.h"
+#include "thread_list.h"
#include "JniConstants.h" // Last to avoid problems with LOG redefinition.
#include "toStringArray.h"
@@ -131,6 +133,13 @@ void VMRuntime_setTargetSdkVersion(JNIEnv* env, jobject, jint targetSdkVersion)
}
}
+void VMRuntime_trimHeap(JNIEnv* env, jobject) {
+ ScopedThreadListLock thread_list_lock;
+ uint64_t start_ns = NanoTime();
+ Heap::GetAllocSpace()->Trim();
+ VLOG(gc) << "VMRuntime_trimHeap took " << PrettyDuration(NanoTime() - start_ns);
+}
+
JNINativeMethod gMethods[] = {
NATIVE_METHOD(VMRuntime, addressOf, "(Ljava/lang/Object;)J"),
NATIVE_METHOD(VMRuntime, bootClassPath, "()Ljava/lang/String;"),
@@ -144,6 +153,7 @@ JNINativeMethod gMethods[] = {
NATIVE_METHOD(VMRuntime, properties, "()[Ljava/lang/String;"),
NATIVE_METHOD(VMRuntime, setTargetSdkVersion, "(I)V"),
NATIVE_METHOD(VMRuntime, startJitCompilation, "()V"),
+ NATIVE_METHOD(VMRuntime, trimHeap, "()V"),
NATIVE_METHOD(VMRuntime, vmVersion, "()Ljava/lang/String;"),
};