rule-reload: Release excess memory freed during engine reload

The hot reload results in large chunks of memory being freed as the
as the old signature tables are discarded. Help the memory management
system along by telling to release as much memory as it can at this
point.

Bug: #6454.
pull/9831/head
Thomas Winter 2 years ago committed by Victor Julien
parent d2b25af3f4
commit 7d40a9f178

@ -220,6 +220,13 @@
#include <sys/random.h>
])
AC_CHECK_HEADERS([malloc.h])
AC_CHECK_DECL([malloc_trim],
AC_DEFINE([HAVE_MALLOC_TRIM], [1], [Use malloc_trim]),
[], [
#include <malloc.h>
])
OCFLAGS=$CFLAGS
CFLAGS=""
AC_CHECK_FUNCS([strlcpy strlcat])

@ -4797,6 +4797,15 @@ int DetectEngineReload(const SCInstance *suri)
SCLogDebug("old_de_ctx should have been freed");
SCLogNotice("rule reload complete");
#ifdef HAVE_MALLOC_TRIM
/* The reload process potentially frees up large amounts of memory.
* Encourage the memory management system to reclaim as much as it
* can.
*/
malloc_trim(0);
#endif
return 0;
}

@ -212,6 +212,10 @@ typedef unsigned char u_char;
#include <netdb.h>
#endif
#if HAVE_MALLOC_H
#include <malloc.h>
#endif
#if __CYGWIN__
#if !defined _X86_ && !defined __x86_64
#define _X86_

Loading…
Cancel
Save