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
(cherry pick commit
d916c233f0ed615667c1c2338c779e819098d135)
Bug:
20554807
Change-Id: Ia9fecea51d2b0a6635e037b5f2bfcb8eb87f4103
import android.os.SystemClock;
import android.util.EventLog;
+import dalvik.system.VMRuntime;
+
import java.lang.ref.WeakReference;
import java.util.ArrayList;
public static void forceGc(String reason) {
EventLog.writeEvent(2741, reason);
- Runtime.getRuntime().gc();
+ VMRuntime.getRuntime().requestConcurrentGC();
}
static void forceBinderGc() {