Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Side by Side Diff: chrome/browser/oom_priority_manager.h

Issue 3235007: This adds periodic OOM score adjustment, based on the last access time (Closed)
Patch Set: Final review changes Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/browser_main.cc ('k') | chrome/browser/oom_priority_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_
OLDNEW
« no previous file with comments | « chrome/browser/browser_main.cc ('k') | chrome/browser/oom_priority_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698