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

Unified 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, 4 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/oom_priority_manager.h
diff --git a/chrome/browser/oom_priority_manager.h b/chrome/browser/oom_priority_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..00734066dfcc6aa67366f931f6008ed11939f4ca
--- /dev/null
+++ b/chrome/browser/oom_priority_manager.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_OOM_PRIORITY_MANAGER_H_
+#define CHROME_BROWSER_OOM_PRIORITY_MANAGER_H_
+
+#include "base/timer.h"
+
+namespace browser {
+
+// The OomPriorityManager periodically checks (see
+// ADJUSTMENT_INTERVAL_SECONDS in the source) the status of renderers
+// and adjusts the out of memory (OOM) adjustment value (in
+// /proc/<pid>/oom_adj) of the renderers so that they match the
+// algorithm embedded here for priority in being killed upon OOM
+// conditions.
+//
+// The algorithm used favors killing tabs that are not pinned, have
+// been idle for longest, and take up the most memory, in that order
+// of priority. We round the idle times to the nearest few minutes
+// (see BUCKET_INTERVAL_MINUTES in the source) so that we can bucket
+// them, as no two tabs will have exactly the same idle time.
+class OomPriorityManager {
+ public:
+ OomPriorityManager();
+ ~OomPriorityManager();
+
+ private:
+ void StartTimer();
+ void StopTimer();
+
+ // Starts DoAdjustOomPriorities on the file threadead. Called when the
+ // timer fires.
+ void AdjustOomPriorities();
+
+ // Called by AdjustOomPriorities. Runs on the file thread.
+ void DoAdjustOomPriorities();
+
+ base::RepeatingTimer<OomPriorityManager> timer_;
+
+ DISALLOW_COPY_AND_ASSIGN(OomPriorityManager);
+};
+} // namespace browser
+
+DISABLE_RUNNABLE_METHOD_REFCOUNT(browser::OomPriorityManager);
+
+#endif // CHROME_BROWSER_OOM_PRIORITY_MANAGER_H_
« 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