[Bug,debuginfod/31103] periodically malloc_trim()

Message ID bug-31103-10460-ytM3TqGitz@http.sourceware.org/bugzilla/
State Not applicable
Headers
Series [Bug,debuginfod/31103] periodically malloc_trim() |

Commit Message

dodji at seketeli dot org March 1, 2024, 11:49 a.m. UTC
  https://sourceware.org/bugzilla/show_bug.cgi?id=31103

--- Comment #1 from Di Chen <dichen at redhat dot com> ---
Hey Frank,

Are you talking about a change like this?

```

   fdcache.limit(0,0,0,0); // release the fdcache contents

```
  

Patch

diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx
index 524be948..fb9c1661 100644
--- a/debuginfod/debuginfod.cxx
+++ b/debuginfod/debuginfod.cxx
@@ -69,6 +69,7 @@  extern "C" {
 #include <unistd.h>
 #include <fcntl.h>
 #include <netdb.h>
+#include <malloc.h>


 /* If fts.h is included before config.h, its indirect inclusions may not
@@ -4197,8 +4198,7 @@  void groom()

   (void) statfs_free_enough_p(db_path, "database"); // report sqlite
filesystem size

-  sqlite3_db_release_memory(db); // shrink the process if possible
-  sqlite3_db_release_memory(dbq); // ... for both connections
+  malloc_trim(0);
   debuginfod_pool_groom(); // and release any debuginfod_client objects we've
been holding onto