[gnome-settings-daemon/wip/chergert/mem-reduce: 7/8] datetime: release weather tzdb information
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/wip/chergert/mem-reduce: 7/8] datetime: release weather tzdb information
- Date: Fri, 20 Mar 2020 10:22:14 +0000 (UTC)
commit a9043a749b1f8db42c71ef90465cc903278ed2c9
Author: Christian Hergert <chergert redhat com>
Date: Tue Mar 10 19:05:25 2020 -0700
datetime: release weather tzdb information
We only need this once when starting up, so this tries to reduce the
memory footprint by dropping that memory after caching a copy of the
information we actually care about.
plugins/datetime/meson.build | 3 ++-
plugins/datetime/weather-tz.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
---
diff --git a/plugins/datetime/meson.build b/plugins/datetime/meson.build
index ed2d433f..0913ddcb 100644
--- a/plugins/datetime/meson.build
+++ b/plugins/datetime/meson.build
@@ -23,7 +23,8 @@ deps = plugins_deps + [
libgeoclue_dep,
libnotify_dep,
m_dep,
- polkit_gobject_dep
+ polkit_gobject_dep,
+ cc.find_library('dl', required: false),
]
cflags += ['-DGNOMECC_DATA_DIR="@0@"'.format(gsd_pkgdatadir)]
diff --git a/plugins/datetime/weather-tz.c b/plugins/datetime/weather-tz.c
index 09995ea4..f4afdaca 100644
--- a/plugins/datetime/weather-tz.c
+++ b/plugins/datetime/weather-tz.c
@@ -19,6 +19,12 @@
#include "config.h"
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE
+#endif
+
+#include <dlfcn.h>
+
#include "weather-tz.h"
#include "tz.h"
@@ -88,6 +94,30 @@ weather_tz_db_populate_locations (WeatherTzDB *tzdb,
}
}
+static void
+release_world (void)
+{
+ void (*release_world_func) (void) = NULL;
+
+ /* libgweather holds on to a great deal of memory in the default
+ * world instance. We do not need this after parsing, so we can release
+ * it all by finding the exported _gweather_location_reset_world() symbol
+ * and calling it.
+ *
+ * This should really be fixed in libgweather, but to prove it's an issue,
+ * we can test things here first.
+ */
+
+ release_world_func = dlsym (RTLD_NEXT, "_gweather_location_reset_world");
+ if (release_world_func != NULL) {
+ g_debug ("Releasing Locations.xml data");
+ release_world_func ();
+ }
+ else {
+ g_debug ("Cannot locate symbol _gweather_location_reset_world()");
+ }
+}
+
WeatherTzDB *
weather_tz_db_new (void)
{
@@ -97,6 +127,8 @@ weather_tz_db_new (void)
tzdb->tz_locations = g_array_new (FALSE, FALSE, sizeof (TzLocation));
load_timezones (tzdb->tz_locations, gweather_location_get_world ());
+ release_world ();
+
return tzdb;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]