OSDN Git Service

Ignore heap trim requests if we are the zygote
authorMathieu Chartier <mathieuc@google.com>
Mon, 8 Sep 2014 20:35:11 +0000 (13:35 -0700)
committerMathieu Chartier <mathieuc@google.com>
Mon, 8 Sep 2014 23:10:12 +0000 (16:10 -0700)
Done to prevent app launching lag due to sleep in heap trimmer
daemon.

Bug: 17310019

(cherry picked from commit f81bfa3e21c8a4e031505470ea954c93949cb30b)

Change-Id: I3942d465781218aa04f7edc899ea87aa091f3cf7

runtime/gc/heap.cc

index f95a68e..2048160 100644 (file)
@@ -3013,7 +3013,10 @@ void Heap::RequestHeapTrim() {
 
   Thread* self = Thread::Current();
   Runtime* runtime = Runtime::Current();
-  if (runtime == nullptr || !runtime->IsFinishedStarting() || runtime->IsShuttingDown(self)) {
+  if (runtime == nullptr || !runtime->IsFinishedStarting() || runtime->IsShuttingDown(self) ||
+      runtime->IsZygote()) {
+    // Ignore the request if we are the zygote to prevent app launching lag due to sleep in heap
+    // trimmer daemon. b/17310019
     // Heap trimming isn't supported without a Java runtime or Daemons (such as at dex2oat time)
     // Also: we do not wish to start a heap trim if the runtime is shutting down (a racy check
     // as we don't hold the lock while requesting the trim).