raster pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=af0d44a57dbb69ea3f597c33ec890a9f81687ee9

commit af0d44a57dbb69ea3f597c33ec890a9f81687ee9
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Thu Jan 16 15:33:37 2020 +0000

    mem trimming - have e trim its own memory every now and again
    
    use malloc_trim() if it exists to do this every now and again
    (idle_enterer if there isa gap > 10 sec since last clean cycle
    so no added wakeups).
---
 src/bin/e.h      |  4 ++++
 src/bin/e_main.c | 17 +++++++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/bin/e.h b/src/bin/e.h
index abe5ed731..2cddb31a5 100644
--- a/src/bin/e.h
+++ b/src/bin/e.h
@@ -104,6 +104,10 @@ void *alloca (size_t);
 #  include <execinfo.h>
 # endif
 
+# ifdef HAVE_MALLOC_H
+#  include <malloc.h>
+# endif
+
 // XXX: FIXME: TMP solution for window stack until api is settled
 #define EFL_BETA_API_SUPPORT
 
diff --git a/src/bin/e_main.c b/src/bin/e_main.c
index 73489167b..9ef3141cf 100644
--- a/src/bin/e_main.c
+++ b/src/bin/e_main.c
@@ -1752,10 +1752,23 @@ _e_main_cb_idle_after(void *data EINA_UNUSED)
    edje_freeze();
 
    if (first_idle)
-     TS("SLEEP");
-   first_idle = 0;
+     {
+        TS("SLEEP");
+        first_idle = 0;
+     }
    e_precache_end = EINA_TRUE;
 
+// every now and again trim malloc memory to stay lean-ish
+#ifdef HAVE_MALLOC_TRIM
+   static double t_last_clean = 0.0;
+   double t = ecore_time_get();
+   if ((t - t_last_clean) > 10.0)
+     {
+        t_last_clean = t;
+        malloc_trim(0);
+     }
+#endif
+
    return ECORE_CALLBACK_RENEW;
 }
 

-- 


Reply via email to