ART GC

2017-07-31  本文已影响0人  dexteryu
Java堆
GC的类型
// 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);
        }
// heap.cc: UpdateProcessState
void Heap::UpdateProcessState(ProcessState old_process_state, ProcessState new_process_state) {
  if (old_process_state != new_process_state) {
    const bool jank_perceptible = new_process_state == kProcessStateJankPerceptible;
    if (jank_perceptible) {
      RequestCollectorTransition(foreground_collector_type_, 0);
    } else {
      RequestCollectorTransition(background_collector_type_,
                                 kIsDebugBuild ? 0 : kCollectorTransitionWait);
    }
  }
}
相关资料
上一篇 下一篇

猜你喜欢

热点阅读