Optimization of malloc usage for small chunks. Reduces memory fragmentation. diff --git a/configure.in b/configure.in index b01cae7..040c9ba 100644 --- a/configure.in +++ b/configure.in @@ -354,6 +354,7 @@ fi AC_CHECK_FUNCS(getgrouplist) AC_CHECK_FUNCS(asprintf) +AC_CHECK_FUNCS(mallopt) # DocBook Documentation diff --git a/hald/hald.c b/hald/hald.c index 4e3c8da..d946c4e 100644 --- a/hald/hald.c +++ b/hald/hald.c @@ -41,7 +41,9 @@ #include #include #include - +#include +#include +#include #include #include #include @@ -374,6 +376,19 @@ main (int argc, char *argv[]) openlog ("hald", LOG_PID, LOG_DAEMON); +#ifdef HAVE_MALLOPT + +#define HAL_MMAP_THRESHOLD 100 +#define HAL_TRIM_THRESHOLD 100 + + /* We use memory in small chunks, thus optimize + it this way. + */ + mallopt(M_MMAP_THRESHOLD, HAL_MMAP_THRESHOLD); + mallopt(M_TRIM_THRESHOLD, HAL_TRIM_THRESHOLD); + +#endif + #ifdef HALD_MEMLEAK_DBG /*g_mem_set_vtable (glib_mem_profiler_table);*/ #endif