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 <lin.zang@intel.com>
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index a41d65c..7a5e546 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -3384,6 +3384,8 @@
// 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_) {