e system - force a malloc trim regularly to keep back-end proc minimal

enlightenment-0.24
Carsten Haitzler 4 years ago
parent 63ae3290fb
commit 5b5c7c3cb3
  1. 6
      meson.build
  2. 3
      src/bin/system/e_system.h
  3. 13
      src/bin/system/e_system_main.c

@ -154,6 +154,12 @@ if cc.has_header('sys/procctl.h') == true
config_h.set('HAVE_PROCCTL' , '1')
endif
if cc.has_header('malloc.h') == true
config_h.set('HAVE_MALLOC_H' , '1')
endif
if cc.has_function('malloc_trim') == true
config_h.set('HAVE_MALLOC_TRIM' , '1')
endif
if cc.has_function('setenv') == true
config_h.set('HAVE_SETENV' , '1')
endif

@ -66,6 +66,9 @@ void *alloca (size_t);
# include <inttypes.h>
# include <assert.h>
# include <fcntl.h>
# ifdef HAVE_MALLOC_H
# include <malloc.h>
# endif
#if defined (__FreeBSD__) || defined (__OpenBSD__)
# include <sys/sysctl.h>

@ -257,6 +257,17 @@ singleton_setup(void)
ecore_thread_feedback_run(_cb_die, NULL, NULL, NULL, NULL, EINA_TRUE);
}
static Eina_Bool
_cb_idle_enterer(void *data EINA_UNUSED)
{
// welcome to unportable code land... :)
// trim process down as much as possible when going idle
#ifdef HAVE_MALLOC_TRIM
malloc_trim(0);
#endif
return ECORE_CALLBACK_RENEW;
}
int
main(int argc EINA_UNUSED, const char **argv EINA_UNUSED)
{
@ -282,6 +293,8 @@ main(int argc EINA_UNUSED, const char **argv EINA_UNUSED)
e_system_l2ping_init();
e_system_cpufreq_init();
ecore_idle_enterer_add(_cb_idle_enterer, NULL);
ecore_main_loop_begin();
e_system_cpufreq_shutdown();

Loading…
Cancel
Save