From: Di Chen <dichen@redhat.com>
To: elfutils-devel@sourceware.org
Subject: [PATCH] debuginfod.cxx: periodically malloc_trim()
Date: Mon, 18 Mar 2024 09:33:24 +0800 [thread overview]
Message-ID: <CAN-Pu7StH+FMXbJLXETf_hNcsHBDy6-J6L5XSiBrJWjW=Hv9WA@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 1231 bytes --]
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
[-- Attachment #2: 0001-debuginfod.cxx-periodically-malloc_trim.patch --]
[-- Type: text/x-patch, Size: 1236 bytes --]
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 reply other threads:[~2024-03-18 1:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-18 1:33 Di Chen [this message]
2024-03-18 20:24 ` Frank Ch. Eigler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAN-Pu7StH+FMXbJLXETf_hNcsHBDy6-J6L5XSiBrJWjW=Hv9WA@mail.gmail.com' \
--to=dichen@redhat.com \
--cc=elfutils-devel@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).