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).
This commit is contained in:
Carsten Haitzler 2020-01-16 15:33:37 +00:00
parent 5b5c7c3cb3
commit af0d44a57d
2 changed files with 19 additions and 2 deletions

View File

@ -104,6 +104,10 @@ void *alloca (size_t);
# include <execinfo.h> # include <execinfo.h>
# endif # endif
# ifdef HAVE_MALLOC_H
# include <malloc.h>
# endif
// XXX: FIXME: TMP solution for window stack until api is settled // XXX: FIXME: TMP solution for window stack until api is settled
#define EFL_BETA_API_SUPPORT #define EFL_BETA_API_SUPPORT

View File

@ -1752,10 +1752,23 @@ _e_main_cb_idle_after(void *data EINA_UNUSED)
edje_freeze(); edje_freeze();
if (first_idle) if (first_idle)
TS("SLEEP"); {
first_idle = 0; TS("SLEEP");
first_idle = 0;
}
e_precache_end = EINA_TRUE; 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; return ECORE_CALLBACK_RENEW;
} }