From d916c233f0ed615667c1c2338c779e819098d135 Mon Sep 17 00:00:00 2001 From: mark_chen Date: Fri, 20 Mar 2015 16:03:55 +0800 Subject: [PATCH] Fix binder force gc will block binder thread Symptom: Force gc caused activity launch time took longer Root Cause: Runtime.getRuntime().gc will block binder thread Solution: Use VMRuntime.requestConcurrentGC() will not block binder thread Bug: 20554807 Change-Id: I48a103c8241c4c85ced4d9a0b231d9f1dc200f35 --- core/java/com/android/internal/os/BinderInternal.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/java/com/android/internal/os/BinderInternal.java b/core/java/com/android/internal/os/BinderInternal.java index 240d9dfd32501..d77b998fa247b 100644 --- a/core/java/com/android/internal/os/BinderInternal.java +++ b/core/java/com/android/internal/os/BinderInternal.java @@ -20,6 +20,8 @@ import android.os.IBinder; import android.os.SystemClock; import android.util.EventLog; +import dalvik.system.VMRuntime; + import java.lang.ref.WeakReference; import java.util.ArrayList; @@ -96,7 +98,7 @@ public class BinderInternal { public static void forceGc(String reason) { EventLog.writeEvent(2741, reason); - Runtime.getRuntime().gc(); + VMRuntime.getRuntime().requestConcurrentGC(); } static void forceBinderGc() {