summaryrefslogtreecommitdiffstats
path: root/runtime/gc
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2015-03-31 16:28:53 -0700
committerMathieu Chartier <mathieuc@google.com>2015-03-31 16:29:46 -0700
commitfaed9950572632ffaac69e70c0b1ab90496c98f3 (patch)
treea8f6f50c35520957188958952fa17935f2624dc6 /runtime/gc
parentbf143069fc5b7526ea79d4283293878a2ebe99ee (diff)
downloadart-faed9950572632ffaac69e70c0b1ab90496c98f3.zip
art-faed9950572632ffaac69e70c0b1ab90496c98f3.tar.gz
art-faed9950572632ffaac69e70c0b1ab90496c98f3.tar.bz2
Only GC the first time we call PreZygoteFork
PreZygoteFork is called for every app launch, it is overkill to GC each time since it takes 20-30ms and blocks app launch for that long. Change-Id: I647c8ccca767ceca67a006c1d80a739c7860f0d0
Diffstat (limited to 'runtime/gc')
-rw-r--r--runtime/gc/heap.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 51cf558..7e967f9 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -2056,7 +2056,11 @@ void Heap::UnBindBitmaps() {
}
void Heap::PreZygoteFork() {
- CollectGarbageInternal(collector::kGcTypeFull, kGcCauseBackground, false);
+ if (!HasZygoteSpace()) {
+ // We still want to GC in case there is some unreachable non moving objects that could cause a
+ // suboptimal bin packing when we compact the zygote space.
+ CollectGarbageInternal(collector::kGcTypeFull, kGcCauseBackground, false);
+ }
Thread* self = Thread::Current();
MutexLock mu(self, zygote_creation_lock_);
// Try to see if we have any Zygote spaces.
@@ -2125,7 +2129,7 @@ void Heap::PreZygoteFork() {
// Update the end and write out image.
non_moving_space_->SetEnd(target_space.End());
non_moving_space_->SetLimit(target_space.Limit());
- VLOG(heap) << "Zygote space size " << non_moving_space_->Size() << " bytes";
+ VLOG(heap) << "Create zygote space with size=" << non_moving_space_->Size() << " bytes";
}
// Change the collector to the post zygote one.
ChangeCollector(foreground_collector_type_);