src/base/util/memory_pressure/system_memory_pressure_evaluator_chromeos.cc
// CalculateAvailableMemoryUserSpaceKB implements the same available memory
// calculation as kernel function get_available_mem_adj().  The available memory
// consists of 3 parts: the free memory, the file cache, and the swappable
// memory.  The available free memory is free memory minus reserved free memory.
// The available file cache is the total file cache minus reserved file cache
// (min_filelist).  Because swapping is prohibited if there is no anonymous
// memory or no swap free, the swappable memory is the minimal of anonymous
// memory and swap free.  As swapping memory is more costly than dropping file
// cache, only a fraction (1 / ram_swap_weight) of the swappable memory
// contributes to the available memory.
CalculateAvailableMemoryUserSpaceKB implements the same available memory
calculation as kernel function get_available_mem_adj().  The available memory
consists of 3 parts: the free memory, the file cache, and the swappable
memory.  The available free memory is free memory minus reserved free memory.
The available file cache is the total file cache minus reserved file cache
(min_filelist).  Because swapping is prohibited if there is no anonymous
memory or no swap free, the swappable memory is the minimal of anonymous
memory and swap free.  As swapping memory is more costly than dropping file
cache, only a fraction (1 / ram_swap_weight) of the swappable memory
contributes to the available memory.
CalculateAvailableMemoryUserSpaceKB implements the same available memory calculation as kernel function get_available_mem_adj () . The available memory consists of 3 parts : the free memory the file cache and the swappable memory . The available free memory is free memory minus reserved free memory . The available file cache is the total file cache minus reserved file cache ( min_filelist ) . Because swapping is prohibited if there is no anonymous memory or no swap free the swappable memory is the minimal of anonymous memory and swap free . As swapping memory is more costly than dropping file cache only a fraction ( 1 / ram_swap_weight ) of the swappable memory contributes to the available memory .
uint64_t SystemMemoryPressureEvaluator::CalculateAvailableMemoryUserSpaceKB(
    const base::SystemMemoryInfoKB& info,
    uint64_t reserved_free,
    uint64_t min_filelist,
    uint64_t ram_swap_weight) {
  const uint64_t free = info.free;
  const uint64_t anon = info.active_anon + info.inactive_anon;
  const uint64_t file = info.active_file + info.inactive_file;
  const uint64_t dirty = info.dirty;
  const uint64_t swap_free = info.swap_free;
  uint64_t available = (free > reserved_free) ? free - reserved_free : 0;
  available += (file > dirty + min_filelist) ? file - dirty - min_filelist : 0;
  available += std::min<uint64_t>(anon, swap_free) / ram_swap_weight;
  return available;
}
uint64_t SystemMemoryPressureEvaluator :: CalculateAvailableMemoryUserSpaceKB ( const base :: SystemMemoryInfoKB & info , uint64_t reserved_free , uint64_t min_filelist , uint64_t ram_swap_weight ) { const uint64_t free = info . free ; const uint64_t anon = info . active_anon + info . inactive_anon ; const uint64_t file = info . active_file + info . inactive_file ; const uint64_t dirty = info . dirty ; const uint64_t swap_free = info . swap_free ; uint64_t available = ( free > reserved_free ) ? free - reserved_free : 0 ; available += ( file > dirty + min_filelist ) ? file - dirty - min_filelist : 0 ; available += std :: min < uint64_t > ( anon , swap_free ) / ram_swap_weight ; return available ; }
CalculateAvailableMemoryUserSpaceKB implements the same available memory
calculation as kernel function get_available_mem_adj().
CalculateAvailableMemoryUserSpaceKB implements the same available memory calculation as kernel function get_available_mem_adj () .