From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#45200: [PATCH] Force Glibc to free the memory freed Date: Wed, 03 Feb 2021 22:55:25 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="502"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: fweimer@redhat.com, carlos@redhat.com, hi-angel@yandex.ru, 45200@debbugs.gnu.org To: DJ Delorie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 04 04:56:09 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 1l7VkX-000Acr-5T for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Feb 2021 04:56:09 +0100 Original-Received: from localhost ([::1]:45968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7VkW-0005jC-7H for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Feb 2021 22:56:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7VkP-0005j1-R4 for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 22:56:01 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56074) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7VkP-0005IO-JB for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 22:56:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l7VkP-00009Q-Hy for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 22:56:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Feb 2021 03:56:01 +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.1612410935543 (code B ref 45200); Thu, 04 Feb 2021 03:56:01 +0000 Original-Received: (at 45200) by debbugs.gnu.org; 4 Feb 2021 03:55:35 +0000 Original-Received: from localhost ([127.0.0.1]:39387 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7Vjz-00008g-Iy for submit@debbugs.gnu.org; Wed, 03 Feb 2021 22:55:35 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:4047) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7Vjy-00008S-7w for 45200@debbugs.gnu.org; Wed, 03 Feb 2021 22:55:34 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id A2C2480D8E; Wed, 3 Feb 2021 22:55:28 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 126D4805B2; Wed, 3 Feb 2021 22:55:27 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1612410927; bh=1A6zsPD3NZCcvjlcjE6Mte4HW7EaGsbNTC1Xfq9ogDI=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=kj5C5U4KBsMtqm42GcnD0r75Oad+j9G/67RlEq9M6PTDMVRyzTh2bcP9lw1u91DEc 1Iq2811vz5t+hBLTl9cScqXxLc/l/9100vJep+NAer54PktPm6zCaV4T5bjPYXBmPc zBy18lftBY5/Ri7duk/MM9sqMJqehNgv7MhI5bIg7K0csshcdw80+0v+IhIeanZMqj CGXUVdWwgx5sWFHLRgVr8LfqJmV65fh3+i6v+ZXIWiNwJm0L6aWjOxb3zx8MG82nOw JArfBzBDI4TK5x74n/hTdG40r/XZNC7ivhDkiVISgQy80EzqlJzKVcmbfvSb5QzvJT mGA3TUWtDBkHw== Original-Received: from alfajor (76-10-182-85.dsl.teksavvy.com [76.10.182.85]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A568412021C; Wed, 3 Feb 2021 22:55:26 -0500 (EST) In-Reply-To: (DJ Delorie's message of "Wed, 03 Feb 2021 22:38:04 -0500") 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:199262 Archived-At: >>> No. Even the tiniest allocation still in use at the top of the heap >>> locks the entire rest of the heap into memory. >> >> Hmm... then I don't understand: the user who reports the problem with >> Emacs claims that calling `malloc_trim` reduces the PSS size of >> Emacs tremendously (from 260MB down to 60MB). >> >> If `malloc_trim` can't release memory other than at the top, then how >> come glibc didn't recover those 200MB on its own (e.g. it seems 200MB >> is well beyond the default value of M_TRIM_THRESHOLD)? > > Well, let me make up a case that "works" and you tell me if this is > common in emacs. > > Consider you've spent the day doing normal things and your heap is at > 100 Mb. Now you do something memory-intensive for a few minutes, and > stop, and gc runs. That "something" allocates a lot of memory, but it's > all going to be at the top of the heap - aside from whatever fits in the > first 100 Mb. It's all released, and GC free()'s it all. malloc_trim() > at this point would coalesce it and return it to the system. But wouldn't glibc release that memory even without calling `malloc_trim` simply because it's at the top and is larger than `M_TRIM_THRESHOLD`? Stefan