OSDN Git Service

ART: correct native bytes allocated in RegisterNativeAllocation
authorLin Zang <lin.zang@intel.com>
Tue, 10 Mar 2015 10:53:21 +0000 (18:53 +0800)
committerLin Zang <lin.zang@intel.com>
Thu, 12 Mar 2015 10:34:04 +0000 (18:34 +0800)
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 <lin.zang@intel.com>
runtime/gc/heap.cc

index a41d65c..7a5e546 100644 (file)
@@ -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_) {