debuginfod.cxx: periodically malloc_trim()
Commit Message
From 93cfe0b3e8d51eb18c5807e4b72c17920aefb422 Mon Sep 17 00:00:00 2001
From: Di Chen <dichen@redhat.com>
Date: Mon, 18 Mar 2024 09:06:19 +0800
Subject: [PATCH] debuginfod.cxx: periodically malloc_trim()
Add malloc_trim() for releasing memory which is allocated for temporary
purposes, e.g. answering queries, adding data to the database during
scans.
https://sourceware.org/bugzilla/show_bug.cgi?id=31103
Signed-off-by: Di Chen <dichen@redhat.com>
---
debuginfod/debuginfod.cxx | 2 ++
1 file changed, 2 insertions(+)
#if 0 /* PR31265: don't jettison cache unnecessarily */
Comments
Hi -
> From: Di Chen <dichen@redhat.com>
> Date: Mon, 18 Mar 2024 09:06:19 +0800
> Subject: [PATCH] debuginfod.cxx: periodically malloc_trim()
>
> Add malloc_trim() for releasing memory which is allocated for temporary
> purposes, e.g. answering queries, adding data to the database during
> scans.
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=31103
>
> Signed-off-by: Di Chen <dichen@redhat.com>
> [...]
Thanks, will merge this with a bit of configury added.
- FChE
From 93cfe0b3e8d51eb18c5807e4b72c17920aefb422 Mon Sep 17 00:00:00 2001
From: Di Chen <dichen@redhat.com>
Date: Mon, 18 Mar 2024 09:06:19 +0800
Subject: [PATCH] debuginfod.cxx: periodically malloc_trim()
Add malloc_trim() for releasing memory which is allocated for temporary
purposes, e.g. answering queries, adding data to the database during
scans.
https://sourceware.org/bugzilla/show_bug.cgi?id=31103
Signed-off-by: Di Chen <dichen@redhat.com>
---
debuginfod/debuginfod.cxx | 2 ++
1 file changed, 2 insertions(+)
@@ -70,6 +70,7 @@ extern "C" {
#include <fcntl.h>
#include <netdb.h>
#include <math.h>
+#include <malloc.h>
#include <float.h>
@@ -4225,6 +4226,7 @@ void groom()
sqlite3_db_release_memory(db); // shrink the process if possible
sqlite3_db_release_memory(dbq); // ... for both connections
+ malloc_trim(0); // PR31103: release memory allocated for temporary purposes
debuginfod_pool_groom(); // and release any debuginfod_client objects we've been holding onto
#if 0 /* PR31265: don't jettison cache unnecessarily */
--
2.41.0