// heap.cc: CollectGarbageInternal
collector::GcType Heap::CollectGarbageInternal(collector::GcType gc_type,
GcCause gc_cause,
bool clear_soft_references) {
collector->Run(gc_cause, clear_soft_references || runtime->IsZygote());
RequestTrim(self);
// Grow the heap so that we know when to perform the next GC.
GrowForUtilization(collector, bytes_allocated_before_gc);
Dbg::GcDidFinish();
return gc_type;
}
Foreground GC和Background GC切换
// ActivityThread.scheduleLaunchActivity
public final void scheduleLaunchActivity(Intent intent, IBinder token, int ident) {
updateProcessState(procState, false);
sendMessage(H.LAUNCH_ACTIVITY, r);
}