[tracker/tracker-0.6] Lower tracker-extract's OOM score to the minimum.
- From: Carlos Garnacho <carlosg src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker/tracker-0.6] Lower tracker-extract's OOM score to the minimum.
- Date: Fri, 12 Jun 2009 12:06:55 -0400 (EDT)
commit aa8a4c5299ed0e0e731b9f22c04ddfa7095ea441
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Jun 12 18:04:07 2009 +0200
Lower tracker-extract's OOM score to the minimum.
This would make tracker-extract the most likely option if the kernel OOM
handler kicks in.
src/libtracker-common/tracker-os-dependant-unix.c | 28 +++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-common/tracker-os-dependant-unix.c b/src/libtracker-common/tracker-os-dependant-unix.c
index 304af4a..9164582 100644
--- a/src/libtracker-common/tracker-os-dependant-unix.c
+++ b/src/libtracker-common/tracker-os-dependant-unix.c
@@ -26,6 +26,8 @@
#include <errno.h>
#include <unistd.h>
#include <sys/resource.h>
+#include <sys/types.h>
+#include <fcntl.h>
#include <glib.h>
@@ -266,6 +268,30 @@ get_memory_total (void)
return total;
}
+static void
+tracker_memory_set_oom_adj (void)
+{
+ const gchar *str = "15";
+ gboolean success = FALSE;
+ int fd;
+
+ fd = open ("/proc/self/oom_adj", O_WRONLY);
+
+ if (fd != -1) {
+ if (write (fd, str, strlen (str)) > 0) {
+ success = TRUE;
+ }
+
+ close (fd);
+ }
+
+ if (success) {
+ g_message ("OOM score has been set to %s", str);
+ } else {
+ g_critical ("Could not adjust OOM score");
+ }
+}
+
gboolean
tracker_memory_setrlimits (void)
{
@@ -318,5 +344,7 @@ tracker_memory_setrlimits (void)
}
#endif /* DISABLE_MEM_LIMITS */
+ tracker_memory_set_oom_adj ();
+
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]