From 8c8f985a5c1593eb70100c2c79137d59caf532fa Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Thu, 8 Mar 2012 23:30:07 +0100 Subject: [PATCH] Disable page cache with < 352 MB RAM --- midori/midori-websettings.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/midori/midori-websettings.c b/midori/midori-websettings.c index 5d3a2f01..d4444ccd 100644 --- a/midori/midori-websettings.c +++ b/midori/midori-websettings.c @@ -344,6 +344,21 @@ midori_get_download_dir (void) } return g_get_home_dir (); } +static gboolean +midori_web_settings_low_memory_profile () +{ + gchar* contents; + const gchar* total; + if (!g_file_get_contents ("/proc/meminfo", &contents, NULL, NULL)) + return FALSE; + if (contents && (total = strstr (contents, "MemTotal:")) && *total) + { + const gchar* value = katze_skip_whitespace (total + 9); + gdouble mem_total = g_ascii_strtoll (value, NULL, 0); + return mem_total / 1024.0 < 352 + 1; + } + return FALSE; +} static void midori_web_settings_class_init (MidoriWebSettingsClass* class) @@ -777,7 +792,7 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class) g_param_spec_boolean ("enable-page-cache", "Enable page cache", "Whether the page cache should be used", - TRUE, + !midori_web_settings_low_memory_profile (), flags)); #endif g_object_class_install_property (gobject_class,