From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: DJ Delorie Newsgroups: gmane.emacs.bugs Subject: bug#45200: [PATCH] Force Glibc to free the memory freed Date: Wed, 03 Feb 2021 19:31:56 -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="5068"; mail-complaints-to="usenet@ciao.gmane.io" Cc: fweimer@redhat.com, carlos@redhat.com, hi-angel@yandex.ru, 45200@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 04 01:47: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 1l7Sno-0001B1-30 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Feb 2021 01:47:20 +0100 Original-Received: from localhost ([::1]:37216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7Snn-00075X-3x for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Feb 2021 19:47:19 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7SZz-0002Em-GT for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 19:33:08 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55921) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7SZy-0000s9-1T for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 19:33:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l7SZx-0003LB-UA for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 19:33:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: DJ Delorie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Feb 2021 00:33: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.161239872712779 (code B ref 45200); Thu, 04 Feb 2021 00:33:01 +0000 Original-Received: (at 45200) by debbugs.gnu.org; 4 Feb 2021 00:32:07 +0000 Original-Received: from localhost ([127.0.0.1]:39234 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7SZ5-0003K3-6u for submit@debbugs.gnu.org; Wed, 03 Feb 2021 19:32:07 -0500 Original-Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:41751) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7SZ3-0003Jv-Bm for 45200@debbugs.gnu.org; Wed, 03 Feb 2021 19:32:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612398724; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=yhHAm/K8uHsI7k/9aSpwqXZzhx1pEc7lLUoKf7Kfb6U=; b=OzF1gDxXM4/BVEkHhEh04zHsd/9AcYB7PVQDIItHqB5J3Mgh6J7HzykWYVzCuvl1qj73LP zZWYzqpo6kv0Hp5S53DmRIuJ+6f02f2vsXeTp+N+8Qwwuz0L+crnele+TOM+m05ya4Jzif dbIhCTg5l3f0+u8AVa4x3VwtGME3dJo= Original-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-436-QE3HWAlhPCCp6fEsGJXuow-1; Wed, 03 Feb 2021 19:32:03 -0500 X-MC-Unique: QE3HWAlhPCCp6fEsGJXuow-1 Original-Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E1C1B801963; Thu, 4 Feb 2021 00:32:01 +0000 (UTC) Original-Received: from greed.delorie.com (ovpn-114-77.rdu2.redhat.com [10.10.114.77]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 965FD1971D; Thu, 4 Feb 2021 00:31:58 +0000 (UTC) Original-Received: from greed.delorie.com.redhat.com (localhost [127.0.0.1]) by greed.delorie.com (8.14.7/8.14.7) with ESMTP id 1140VuJA005176; Wed, 3 Feb 2021 19:31:56 -0500 In-Reply-To: (message from Stefan Monnier on Wed, 03 Feb 2021 18:32:36 -0500) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dj@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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:199256 Archived-At: Stefan Monnier writes: >>>> Yet another word of memory used, >>> Since 200MB is peanuts, I figure that extra 24B should be acceptable ;-) >> *per chunk*. > > No, those counters are meant to be global. To clarify, that extra word was the "chunk age" information, not the aggregate metrics. > One thing that remains a bit unclear for me is in the doc of > `malloc_trim`; it says: > > The pad argument specifies the amount of free space to leave untrimmed > at the top of the heap. If this argument is 0, only the minimum amount > of memory is maintained at the top of the heap (i.e., one page or > less). A nonzero argument can be used to maintain some trailing space > at the top of the heap in order to allow future allocations to be made > without having to extend the heap with sbrk(2). > > 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.