debuginfod.cxx: periodically malloc_trim()

Message ID CAN-Pu7StH+FMXbJLXETf_hNcsHBDy6-J6L5XSiBrJWjW=Hv9WA@mail.gmail.com
State Committed
Headers
Series debuginfod.cxx: periodically malloc_trim() |

Commit Message

Di Chen March 18, 2024, 1:33 a.m. UTC
  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

Frank Ch. Eigler March 18, 2024, 8:24 p.m. UTC | #1
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
  

Patch

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(+)

diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx
index 72617848..6e1b43ad 100644
--- a/debuginfod/debuginfod.cxx
+++ b/debuginfod/debuginfod.cxx
@@ -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