From: Linus Nordberg Date: Mon, 26 Aug 2013 10:04:07 +0000 (+0200) Subject: Return free memory more aggressively. X-Git-Tag: radsecproxy-1.6.3-rc0~10 X-Git-Url: http://www.project-moonshot.org/gitweb/?a=commitdiff_plain;h=dbff4652bc09a88e931c859ab63b33e94a2c3ee3;hp=55ca280f16473095380e22c574910f106b11058f;p=radsecproxy.git Return free memory more aggressively. Have free(3) call sbrk(2) when there's 4 MB to free (default on Linux seems to be 128). Patch by Fabian Mauchle. Conflicts: configure.ac --- diff --git a/configure.ac b/configure.ac index 79be2fc..f018e0b 100644 --- a/configure.ac +++ b/configure.ac @@ -3,6 +3,8 @@ AC_CANONICAL_TARGET AM_INIT_AUTOMAKE AC_PROG_CC AC_PROG_RANLIB +AC_CHECK_FUNCS([mallopt]) + udp=yes AC_ARG_ENABLE(udp, [ --enable-udp whether to enable UDP transport: yes/no; default yes ], diff --git a/radsecproxy.c b/radsecproxy.c index 56abe3e..d05f9c9 100644 --- a/radsecproxy.c +++ b/radsecproxy.c @@ -52,6 +52,9 @@ #include #include #include +#if defined(HAVE_MALLOPT) +#include +#endif #ifdef SYS_SOLARIS9 #include #endif @@ -3348,6 +3351,10 @@ int radsecproxy_main(int argc, char **argv) { debugx(1, DBG_ERR, "pthread_attr_init failed"); if (pthread_attr_setstacksize(&pthread_attr, PTHREAD_STACK_SIZE)) debugx(1, DBG_ERR, "pthread_attr_setstacksize failed"); +#if defined(HAVE_MALLOPT) + if (mallopt(M_TRIM_THRESHOLD, 4 * 1024) != 1) + debugx(1, DBG_ERR, "mallopt failed"); +#endif for (i = 0; i < RAD_PROTOCOUNT; i++) protodefs[i] = protoinits[i](i);