Add malloc_trim() for releasing memory which is allocated for
temporary purposes, e.g. answering queries, adding data to the
database during scans. This patch just adds one call after the groom
cycle, but others could be added around webapi query handling or
scanning ops too.
Signed-off-by: Di Chen <dichen@redhat.com>
AC_CHECK_FUNCS([sched_getaffinity])
AC_CHECK_HEADERS([sys/resource.h])
AC_CHECK_FUNCS([getrlimit])
+AC_CHECK_HEADERS([malloc.h])
+AC_CHECK_FUNCS([malloc_trim])
old_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -D_GNU_SOURCE"
#include <execinfo.h>
}
#endif
+#ifdef HAVE_MALLOC_H
+extern "C" {
+#include <malloc.h>
+}
+#endif
#include "debuginfod.h"
#include <dwarf.h>
sqlite3_db_release_memory(db); // shrink the process if possible
sqlite3_db_release_memory(dbq); // ... for both connections
debuginfod_pool_groom(); // and release any debuginfod_client objects we've been holding onto
-
-#if 0 /* PR31265: don't jettison cache unnecessarily */
+#if HAVE_MALLOC_TRIM
+ malloc_trim(0); // PR31103: release memory allocated for temporary purposes
+#endif
+#if 0 /* PR31265: don't jettison cache unnecessarily */
fdcache.limit(0); // release the fdcache contents
fdcache.limit(fdcache_mbs); // restore status quo parameters
#endif