From: Mathieu Chartier Date: Mon, 8 Sep 2014 20:35:11 +0000 (-0700) Subject: Ignore heap trim requests if we are the zygote X-Git-Tag: android-x86-7.1-r1~889^2~3146^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=30cbbee37d9fcca1a39b3681434180102ee5251a;p=android-x86%2Fart.git Ignore heap trim requests if we are the zygote Done to prevent app launching lag due to sleep in heap trimmer daemon. Bug: 17310019 (cherry picked from commit f81bfa3e21c8a4e031505470ea954c93949cb30b) Change-Id: I3942d465781218aa04f7edc899ea87aa091f3cf7 --- diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index f95a68ed6..204816037 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -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).