OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/memory_pressure/direct_memory_pressure_calculator_win.h" | 5 #include "components/memory_pressure/direct_memory_pressure_calculator_win.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/process/process_metrics.h" | 8 #include "base/process/process_metrics.h" |
9 | 9 |
10 namespace memory_pressure { | 10 namespace memory_pressure { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 DCHECK_LE(0, critical_threshold_mb_); | 58 DCHECK_LE(0, critical_threshold_mb_); |
59 } | 59 } |
60 | 60 |
61 DirectMemoryPressureCalculator::MemoryPressureLevel | 61 DirectMemoryPressureCalculator::MemoryPressureLevel |
62 DirectMemoryPressureCalculator::CalculateCurrentPressureLevel() { | 62 DirectMemoryPressureCalculator::CalculateCurrentPressureLevel() { |
63 base::SystemMemoryInfoKB mem_info = {}; | 63 base::SystemMemoryInfoKB mem_info = {}; |
64 if (!GetSystemMemoryInfo(&mem_info)) | 64 if (!GetSystemMemoryInfo(&mem_info)) |
65 return MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE; | 65 return MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE; |
66 | 66 |
67 // How much system memory is actively available for use right now, in MBs. | 67 // How much system memory is actively available for use right now, in MBs. |
68 int phys_free = mem_info.avail_phys / kKBperMB; | 68 int phys_free = mem_info.free / kKBperMB; |
69 | 69 |
70 // TODO(chrisha): This should eventually care about address space pressure, | 70 // TODO(chrisha): This should eventually care about address space pressure, |
71 // but the browser process (where this is running) effectively never runs out | 71 // but the browser process (where this is running) effectively never runs out |
72 // of address space. Renderers occasionally do, but it does them no good to | 72 // of address space. Renderers occasionally do, but it does them no good to |
73 // have the browser process monitor address space pressure. Long term, | 73 // have the browser process monitor address space pressure. Long term, |
74 // renderers should run their own address space pressure monitors and act | 74 // renderers should run their own address space pressure monitors and act |
75 // accordingly, with the browser making cross-process decisions based on | 75 // accordingly, with the browser making cross-process decisions based on |
76 // system memory pressure. | 76 // system memory pressure. |
77 | 77 |
78 // Determine if the physical memory is under critical memory pressure. | 78 // Determine if the physical memory is under critical memory pressure. |
(...skipping 28 matching lines...) Expand all Loading... |
107 critical_threshold_mb_ = kLargeMemoryDefaultCriticalThresholdMb; | 107 critical_threshold_mb_ = kLargeMemoryDefaultCriticalThresholdMb; |
108 } else { | 108 } else { |
109 moderate_threshold_mb_ = kSmallMemoryDefaultModerateThresholdMb; | 109 moderate_threshold_mb_ = kSmallMemoryDefaultModerateThresholdMb; |
110 critical_threshold_mb_ = kSmallMemoryDefaultCriticalThresholdMb; | 110 critical_threshold_mb_ = kSmallMemoryDefaultCriticalThresholdMb; |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 #endif // defined(MEMORY_PRESSURE_IS_POLLING) | 114 #endif // defined(MEMORY_PRESSURE_IS_POLLING) |
115 | 115 |
116 } // namespace memory_pressure | 116 } // namespace memory_pressure |
OLD | NEW |