src/base/util/memory_pressure/system_memory_pressure_evaluator_chromeos.cc
// CheckMemoryPressure will get the current memory pressure level by reading
// the available file.
CheckMemoryPressure will get the current memory pressure level by reading
the available file.
CheckMemoryPressure will get the current memory pressure level by reading the available file .
void SystemMemoryPressureEvaluator::CheckMemoryPressure() {
  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
  auto old_vote = current_vote();
  uint64_t mem_avail_mb = GetAvailableMemoryKB() / 1024;
  SetCurrentVote(GetMemoryPressureLevelFromAvailable(
      mem_avail_mb, moderate_pressure_threshold_mb_,
      critical_pressure_threshold_mb_));
  bool notify = true;
  if (current_vote() ==
      base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE) {
    last_moderate_notification_ = base::TimeTicks();
    notify = false;
  }
  else if (current_vote() ==
           base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE) {
    if (old_vote == current_vote()) {
      if (base::TimeTicks::Now() - last_moderate_notification_ <
          kModerateMemoryPressureCooldownTime) {
        notify = false;
      } else if (old_vote ==
                 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) {
        last_moderate_notification_ = base::TimeTicks::Now();
        notify = false;
      }
    }
    if (notify)
      last_moderate_notification_ = base::TimeTicks::Now();
  }
  VLOG(1) << "SystemMemoryPressureEvaluator::CheckMemoryPressure dispatching "
             "at level: "
          << current_vote();
  SendCurrentVote(notify);
}
void SystemMemoryPressureEvaluator :: CheckMemoryPressure ( ) { DCHECK_CALLED_ON_VALID_SEQUENCE ( sequence_checker_ ) ; auto old_vote = current_vote ( ) ; uint64_t mem_avail_mb = GetAvailableMemoryKB ( ) / 1024 ; SetCurrentVote ( GetMemoryPressureLevelFromAvailable ( mem_avail_mb , moderate_pressure_threshold_mb_ , critical_pressure_threshold_mb_ ) ) ; bool notify = true ; if ( current_vote ( ) == base :: MemoryPressureListener :: MEMORY_PRESSURE_LEVEL_NONE ) { last_moderate_notification_ = base :: TimeTicks ( ) ; notify = false ; } else if ( current_vote ( ) == base :: MemoryPressureListener :: MEMORY_PRESSURE_LEVEL_MODERATE ) { if ( old_vote == current_vote ( ) ) { if ( base :: TimeTicks :: Now ( ) - last_moderate_notification_ < kModerateMemoryPressureCooldownTime ) { notify = false ; } else if ( old_vote == base :: MemoryPressureListener :: MEMORY_PRESSURE_LEVEL_CRITICAL ) { last_moderate_notification_ = base :: TimeTicks :: Now ( ) ; notify = false ; } } if ( notify ) last_moderate_notification_ = base :: TimeTicks :: Now ( ) ; } VLOG ( 1 ) << " " " " << current_vote ( ) ; SendCurrentVote ( notify ) ; }
CheckMemoryPressure will get the current memory pressure level by reading
the available file.
CheckMemoryPressure will get the current memory pressure level by reading the available file .
// In the case of MODERATE memory pressure we may be in this state for quite // some time so we limit the rate at which we dispatch notifications. // Reset the moderate notification time if we just crossed back.