From: Lin Zang Date: Tue, 10 Mar 2015 10:53:21 +0000 (+0800) Subject: ART: correct native bytes allocated in RegisterNativeAllocation X-Git-Tag: android-x86-7.1-r1~889^2~1827^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=60e27165e13a8401ded88c492ab804419537b2c7;p=android-x86%2Fart.git ART: correct native bytes allocated in RegisterNativeAllocation Fix the issue that in RegisterNativeAllocation the new_native_bytes_allocated was not updated after Runfinalization, which may cause unnecessary GC. Change-Id: Icbbc0d1cbcd7b1b8e42576104de69c8ff3afa745 Signed-off-by: Lin Zang --- diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index a41d65ce4..7a5e546ff 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -3384,6 +3384,8 @@ void Heap::RegisterNativeAllocation(JNIEnv* env, size_t bytes) { // Just finished a GC, attempt to run finalizers. RunFinalization(env); CHECK(!env->ExceptionCheck()); + // Native bytes allocated may be updated by finalization, refresh it. + new_native_bytes_allocated = native_bytes_allocated_.LoadRelaxed(); } // If we still are over the watermark, attempt a GC for alloc and run finalizers. if (new_native_bytes_allocated > growth_limit_) {