OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_OOM_PRIORITY_MANAGER_H_ |
| 6 #define CHROME_BROWSER_OOM_PRIORITY_MANAGER_H_ |
| 7 |
| 8 #include "base/timer.h" |
| 9 |
| 10 namespace browser { |
| 11 |
| 12 // The OomPriorityManager periodically checks (see |
| 13 // ADJUSTMENT_INTERVAL_SECONDS in the source) the status of renderers |
| 14 // and adjusts the out of memory (OOM) adjustment value (in |
| 15 // /proc/<pid>/oom_adj) of the renderers so that they match the |
| 16 // algorithm embedded here for priority in being killed upon OOM |
| 17 // conditions. |
| 18 // |
| 19 // The algorithm used favors killing tabs that are not pinned, have |
| 20 // been idle for longest, and take up the most memory, in that order |
| 21 // of priority. We round the idle times to the nearest few minutes |
| 22 // (see BUCKET_INTERVAL_MINUTES in the source) so that we can bucket |
| 23 // them, as no two tabs will have exactly the same idle time. |
| 24 class OomPriorityManager { |
| 25 public: |
| 26 OomPriorityManager(); |
| 27 ~OomPriorityManager(); |
| 28 |
| 29 private: |
| 30 void StartTimer(); |
| 31 void StopTimer(); |
| 32 |
| 33 // Starts DoAdjustOomPriorities on the file threadead. Called when the |
| 34 // timer fires. |
| 35 void AdjustOomPriorities(); |
| 36 |
| 37 // Called by AdjustOomPriorities. Runs on the file thread. |
| 38 void DoAdjustOomPriorities(); |
| 39 |
| 40 base::RepeatingTimer<OomPriorityManager> timer_; |
| 41 |
| 42 DISALLOW_COPY_AND_ASSIGN(OomPriorityManager); |
| 43 }; |
| 44 } // namespace browser |
| 45 |
| 46 DISABLE_RUNNABLE_METHOD_REFCOUNT(browser::OomPriorityManager); |
| 47 |
| 48 #endif // CHROME_BROWSER_OOM_PRIORITY_MANAGER_H_ |
OLD | NEW |