[tracker-miners] tracker-miner-fs: Use GMemoryMonitor if available
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners] tracker-miner-fs: Use GMemoryMonitor if available
- Date: Sun, 30 Aug 2020 21:48:59 +0000 (UTC)
commit 191cc5218b53fba85baec1c8c17bb246a74044c0
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Aug 30 22:49:20 2020 +0200
tracker-miner-fs: Use GMemoryMonitor if available
Ensure to return as much memory as possible on memory pressure situations
src/miners/fs/tracker-main.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
---
diff --git a/src/miners/fs/tracker-main.c b/src/miners/fs/tracker-main.c
index 0c9ed2ac3..c60070d04 100644
--- a/src/miners/fs/tracker-main.c
+++ b/src/miners/fs/tracker-main.c
@@ -444,6 +444,17 @@ cleanup_cb (gpointer user_data)
return G_SOURCE_REMOVE;
}
+#if GLIB_CHECK_VERSION (2, 64, 0)
+static void
+on_low_memory (GMemoryMonitor *monitor,
+ GMemoryMonitorWarningLevel level,
+ gpointer user_data)
+{
+ if (level > G_MEMORY_MONITOR_WARNING_LEVEL_LOW)
+ malloc_trim (0);
+}
+#endif
+
static void
miner_started_cb (TrackerMinerFS *fs)
{
@@ -930,6 +941,9 @@ main (gint argc, gchar *argv[])
TrackerEndpointDBus *endpoint;
TrackerDomainOntology *domain_ontology;
GCancellable *cancellable;
+#if GLIB_CHECK_VERSION (2, 64, 0)
+ GMemoryMonitor *memory_monitor;
+#endif
gchar *domain_name, *dbus_name;
main_loop = NULL;
@@ -1115,10 +1129,18 @@ main (gint argc, gchar *argv[])
tracker_miner_files_set_mtime_checking (TRACKER_MINER_FILES (miner_files), do_mtime_checking);
}
+ g_signal_connect (miner_files, "started",
+ G_CALLBACK (miner_started_cb),
+ NULL);
g_signal_connect (miner_files, "finished",
G_CALLBACK (miner_finished_cb),
NULL);
+#if GLIB_CHECK_VERSION (2, 64, 0)
+ memory_monitor = g_memory_monitor_dup_default ();
+ g_signal_connect (memory_monitor, "low-memory-warning", on_low_memory, NULL);
+#endif
+
/* Preempt creation of graphs */
tracker_sparql_connection_update_async (tracker_miner_get_connection (miner_files),
"CREATE SILENT GRAPH tracker:FileSystem; "
@@ -1161,6 +1183,11 @@ main (gint argc, gchar *argv[])
tracker_sparql_connection_close (sparql_conn);
g_object_unref (sparql_conn);
+#if GLIB_CHECK_VERSION (2, 64, 0)
+ g_signal_handlers_disconnect_by_func (memory_monitor, on_low_memory, NULL);
+ g_object_unref (memory_monitor);
+#endif
+
g_print ("\nOK\n\n");
return EXIT_SUCCESS;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]