Skip to content

Commit

Permalink
Return free memory more aggressively.
Browse files Browse the repository at this point in the history
Have free(3) call sbrk(2) when there's 4 MB to free (default on Linux
seems to be 128).

Patch by Fabian Mauchle.
  • Loading branch information
Linus Nordberg committed Aug 26, 2013
1 parent 9174b0a commit 3bd0555
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
dnl Copyright (c) 2006-2010, UNINETT AS
dnl Copyright (c) 2010-2012, NORDUnet A/S
dnl Copyright (c) 2010-2013, NORDUnet A/S
dnl See LICENSE for licensing information.

AC_INIT(radsecproxy, 1.7-dev, radsecproxy@uninett.no)
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 ],
Expand Down
7 changes: 7 additions & 0 deletions radsecproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
#include <string.h>
#include <unistd.h>
#include <limits.h>
#if defined(HAVE_MALLOPT)
#include <malloc.h>
#endif
#ifdef SYS_SOLARIS9
#include <fcntl.h>
#endif
Expand Down Expand Up @@ -3335,6 +3338,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);
Expand Down

0 comments on commit 3bd0555

Please sign in to comment.