GNU bug report logs - #45200
Wishlist: There should be a `malloc-trim' function

Previous Next

Package: emacs;

Reported by: Konstantin Kharlamov <hi-angel <at> yandex.ru>

Date: Sat, 12 Dec 2020 18:44:02 UTC

Severity: wishlist

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #26 received at 45200 <at> debbugs.gnu.org (full text, mbox):

From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
To: 45200 <at> debbugs.gnu.org
Subject: [PATCH] Force Glibc to free the memory freed
Date: Sun, 24 Jan 2021 18:24:02 +0300
configure.ac: check whether malloc_trim is suported
src/alloc.c (lisp_free): call malloc_trim() if possible
(bug#45200)
---
 configure.ac | 3 +++
 src/alloc.c  | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/configure.ac b/configure.ac
index bcc0be7de0..3e0459a0e2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4544,6 +4544,9 @@ AC_DEFUN
 dnl the current CFLAGS etc.
 AC_CHECK_FUNCS(snprintf)
 
+
+AC_CHECK_FUNCS(malloc_trim)
+
 dnl Check for glib.  This differs from other library checks in that
 dnl Emacs need not link to glib unless some other library is already
 dnl linking to glib.  Although glib provides no facilities that Emacs
diff --git a/src/alloc.c b/src/alloc.c
index c0a55e61b9..97e3ceb52c 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -1047,6 +1047,9 @@ lisp_free (void *block)
 
   MALLOC_BLOCK_INPUT;
   free (block);
+#ifdef HAVE_MALLOC_TRIM
+  malloc_trim(0); /* work around for high memory consumption, see bug 45200 */
+#endif /* HAVE_MALLOC_TRIM */
 #ifndef GC_MALLOC_CHECK
   mem_delete (mem_find (block));
 #endif
-- 
2.30.0





This bug report was last modified 3 years and 78 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.