Move SwapBitmaps to ContinuousMemMapAllocSpace.
Moved the SwapBitmaps function to ContinuousMemMapAllocSpace since
the zygote space uses this function during full GC.
Fixed a place where we were casting a ZygoteSpace to a MallocSpace,
somehow this didn't cause any issues in non-debug builds.
Moved the CollectGarbage in PreZygoteFork before the lock to prevent
an occasional lock level violation caused by attempting to enqueue
java lang references with the a lock.
Bug: 12876255
Change-Id: I77439e46d5b26b37724bdcee3a0948410f1b0eb4
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index eb38310..309adb7 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -1431,6 +1431,7 @@
}
void Heap::PreZygoteFork() {
+ CollectGarbageInternal(collector::kGcTypeFull, kGcCauseBackground, false);
static Mutex zygote_creation_lock_("zygote creation lock", kZygoteCreationLock);
Thread* self = Thread::Current();
MutexLock mu(self, zygote_creation_lock_);
@@ -1439,7 +1440,6 @@
return;
}
VLOG(heap) << "Starting PreZygoteFork";
- CollectGarbageInternal(collector::kGcTypeFull, kGcCauseBackground, false);
// Trim the pages at the end of the non moving space.
non_moving_space_->Trim();
non_moving_space_->GetMemMap()->Protect(PROT_READ | PROT_WRITE);