public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] debuginfod.cxx: periodically malloc_trim()
@ 2024-03-18  1:33 Di Chen
  2024-03-18 20:24 ` Frank Ch. Eigler
  0 siblings, 1 reply; 2+ messages in thread
From: Di Chen @ 2024-03-18  1:33 UTC (permalink / raw)
  To: elfutils-devel


[-- 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] debuginfod.cxx: periodically malloc_trim()
  2024-03-18  1:33 [PATCH] debuginfod.cxx: periodically malloc_trim() Di Chen
@ 2024-03-18 20:24 ` Frank Ch. Eigler
  0 siblings, 0 replies; 2+ messages in thread
From: Frank Ch. Eigler @ 2024-03-18 20:24 UTC (permalink / raw)
  To: Di Chen; +Cc: elfutils-devel

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-18 20:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-18  1:33 [PATCH] debuginfod.cxx: periodically malloc_trim() Di Chen
2024-03-18 20:24 ` Frank Ch. Eigler

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).