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:26:29 -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="40487"; 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:27:22 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 1l7VIg-000APX-40 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Feb 2021 04:27:22 +0100 Original-Received: from localhost ([::1]:55120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7VIf-0004aD-4m for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Feb 2021 22:27:21 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7VIQ-0004YD-1h for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 22:27:06 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56064) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7VIP-0001Ql-Qo for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 22:27:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l7VIP-0007ga-Nj for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 22:27:05 -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:27:05 +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.161240920029436 (code B ref 45200); Thu, 04 Feb 2021 03:27:05 +0000 Original-Received: (at 45200) by debbugs.gnu.org; 4 Feb 2021 03:26:40 +0000 Original-Received: from localhost ([127.0.0.1]:39367 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7VHz-0007ei-UB for submit@debbugs.gnu.org; Wed, 03 Feb 2021 22:26:40 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:8700) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7VHx-0007eR-VA for 45200@debbugs.gnu.org; Wed, 03 Feb 2021 22:26:38 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 775E9101F42; Wed, 3 Feb 2021 22:26:32 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id E70F3100DB3; Wed, 3 Feb 2021 22:26:30 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1612409190; bh=Erd9LRnCA71m3WRdClw0r71DFNYgGztwoC9Ig5C1YFA=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=MECiFCO+CnzgVFl0fuJZ//Kt8amp+p/Bfuw0WsCfrsAUi4csfqPxIg1lJVyua5sI8 sCYvbud2iaL6UnW8uK23cN0DfKom1JRk2U5A99XtlXbNY6ReVlkkmcSFpiDAWAQ40a nNlZjsNHMrHeZHjpdYqrDs4IPUdxEz7nl2e2SBUBMQ+foRLsbgc9hJPzyZBw+sPHvk ++dwo7g+ijubIQ3ohirM7MWlUPg23d7CHk3PyNMq7gf6q8+CWlaWm0e0xVPWR87PyC Lsk2Y4MQx4Fpa4xZBAHsYw2mR0B24NN04Qh6MykgPkb3T+f6dF3B9VxvMVFzhiY4/p MKaPQ+Hf7x+qw== Original-Received: from alfajor (76-10-182-85.dsl.teksavvy.com [76.10.182.85]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9732512021C; Wed, 3 Feb 2021 22:26:30 -0500 (EST) In-Reply-To: (DJ Delorie's message of "Wed, 03 Feb 2021 19:31:56 -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:199260 Archived-At: >> But this only talks about the free space at the "top". Since in our >> case most of the free space is not at the top, I wonder: >> say we have 64KB free at the top and 64MB free elsewhere and we call >> `malloc_trim` with a `pad` of 16MB, will it release ~48MB of the >> non-top free memory or will it free all 64MB of the non-top free memory >> or ... ? > > 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)? Stefan