[PATCH] debuginfod.cxx: periodically malloc_trim()
Di Chen
dichen@redhat.com
Mon Mar 18 01:33:24 GMT 2024
>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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/elfutils-devel/attachments/20240318/93a863eb/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-debuginfod.cxx-periodically-malloc_trim.patch
Type: text/x-patch
Size: 1236 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/elfutils-devel/attachments/20240318/93a863eb/attachment.bin>
More information about the Elfutils-devel
mailing list