From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#45200: [PATCH] Force Glibc to free the memory freed Date: Sun, 24 Jan 2021 17:40:29 +0200 Message-ID: <834kj64a36.fsf@gnu.org> References: <20210124152402.40270-1-Hi-Angel@yandex.ru> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22558"; mail-complaints-to="usenet@ciao.gmane.io" Cc: carlos@redhat.com, fweimer@redhat.com, monnier@iro.umontreal.ca, dj@redhat.com, 45200@debbugs.gnu.org To: Konstantin Kharlamov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 24 16:41:10 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l3hVm-0005jd-11 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 24 Jan 2021 16:41:10 +0100 Original-Received: from localhost ([::1]:34466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l3hVk-0002ya-KP for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 24 Jan 2021 10:41:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l3hVe-0002yS-Kz for bug-gnu-emacs@gnu.org; Sun, 24 Jan 2021 10:41:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53679) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l3hVe-0006Fu-Dj for bug-gnu-emacs@gnu.org; Sun, 24 Jan 2021 10:41:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l3hVe-00018S-Ai for bug-gnu-emacs@gnu.org; Sun, 24 Jan 2021 10:41:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 24 Jan 2021 15:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45200 X-GNU-PR-Package: emacs Original-Received: via spool by 45200-submit@debbugs.gnu.org id=B45200.16115028384322 (code B ref 45200); Sun, 24 Jan 2021 15:41:02 +0000 Original-Received: (at 45200) by debbugs.gnu.org; 24 Jan 2021 15:40:38 +0000 Original-Received: from localhost ([127.0.0.1]:36992 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l3hVF-00017e-KV for submit@debbugs.gnu.org; Sun, 24 Jan 2021 10:40:37 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33922) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l3hVB-00017O-GM for 45200@debbugs.gnu.org; Sun, 24 Jan 2021 10:40:37 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:60069) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l3hV5-0005z8-4l; Sun, 24 Jan 2021 10:40:27 -0500 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2771 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l3hV2-000592-NG; Sun, 24 Jan 2021 10:40:26 -0500 In-Reply-To: <20210124152402.40270-1-Hi-Angel@yandex.ru> (message from Konstantin Kharlamov on Sun, 24 Jan 2021 18:24:02 +0300) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:198506 Archived-At: > From: Konstantin Kharlamov > 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 Thanks, but is it really a good idea to call malloc_trim each time we free some chunk of memory? Carlos, Florian, DJ: any thoughts or comments on this proposal? (Let me know if you need some background about the code involved in this.)