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

Unified Diff: base/process_util_linux.cc

Issue 467058: Linux: Adjust /proc/pid/oom_adj to sacrifice plugin and renderer processes to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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
Index: base/process_util_linux.cc
===================================================================
--- base/process_util_linux.cc (revision 34180)
+++ base/process_util_linux.cc (working copy)
@@ -513,7 +513,6 @@
} // namespace
extern "C" {
-
#if !defined(LINUX_USE_TCMALLOC)
typedef void* (*malloc_type)(size_t size);
@@ -600,7 +599,6 @@
}
#endif // !defined(LINUX_USE_TCMALLOC)
-
} // extern C
void EnableTerminationOnOutOfMemory() {
@@ -610,4 +608,20 @@
// malloc and friends and make them die on out of memory.
}
+bool AdjustOOMScore(ProcessId process, int score) {
+ if (score < 0 || score > 15)
+ return false;
+
+ FilePath oom_adj("/proc");
+ oom_adj = oom_adj.Append(Int64ToString(process));
+ oom_adj = oom_adj.AppendASCII("oom_adj");
+
+ if (!file_util::PathExists(oom_adj))
+ return false;
+
+ std::string score_str = IntToString(score);
+ return (static_cast<int>(score_str.length()) ==
+ file_util::WriteFile(oom_adj, score_str.c_str(), score_str.length()));
+}
+
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698