[tracker-miners] tracker-miner-fs: Clear memory after some time idle
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners] tracker-miner-fs: Clear memory after some time idle
- Date: Sun, 30 Aug 2020 21:48:59 +0000 (UTC)
commit ccb0b4ebbff4dfacf17ea67ce56bb27c39741811
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Aug 30 22:44:19 2020 +0200
tracker-miner-fs: Clear memory after some time idle
Be more aggresive at releasing memory and call malloc_trim() after
some time idle.
src/miners/fs/tracker-main.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
---
diff --git a/src/miners/fs/tracker-main.c b/src/miners/fs/tracker-main.c
index 220916dc3..0c9ed2ac3 100644
--- a/src/miners/fs/tracker-main.c
+++ b/src/miners/fs/tracker-main.c
@@ -57,6 +57,7 @@
static GMainLoop *main_loop;
static GDBusProxy *index_proxy;
static GPtrArray *proxy_folders;
+static guint cleanup_id;
static gint initial_sleep = -1;
static gboolean no_daemon;
@@ -432,6 +433,26 @@ miner_start (TrackerMiner *miner,
miner);
}
+static gboolean
+cleanup_cb (gpointer user_data)
+{
+ /* Reclaim as much memory as possible */
+ malloc_trim (0);
+
+ cleanup_id = 0;
+
+ return G_SOURCE_REMOVE;
+}
+
+static void
+miner_started_cb (TrackerMinerFS *fs)
+{
+ if (cleanup_id) {
+ g_source_remove (cleanup_id);
+ cleanup_id = 0;
+ }
+}
+
static void
miner_finished_cb (TrackerMinerFS *fs,
gdouble seconds_elapsed,
@@ -451,6 +472,8 @@ miner_finished_cb (TrackerMinerFS *fs,
TRUE);
}
+ cleanup_id = g_timeout_add_seconds (30, cleanup_cb, NULL);
+
/* We're not sticking around for file updates, so stop
* the mainloop and exit.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]