From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Konstantin Kharlamov Newsgroups: gmane.emacs.bugs Subject: bug#45200: Memory leaks: (garbage-collect) fails to reclaim memory Date: Sun, 24 Jan 2021 22:00:31 +0300 Message-ID: <2a4f3f31f30db28387055821a8edf44fd1d66ea5.camel@yandex.ru> References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36241"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.38.3 Cc: 45200@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 24 20:01:38 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 1l3kdl-0009Ie-Gz for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 24 Jan 2021 20:01:37 +0100 Original-Received: from localhost ([::1]:56740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l3kdk-0000uS-I6 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 24 Jan 2021 14:01:36 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l3kdC-0000bV-Pd for bug-gnu-emacs@gnu.org; Sun, 24 Jan 2021 14:01:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53962) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l3kdC-0002fS-FL for bug-gnu-emacs@gnu.org; Sun, 24 Jan 2021 14:01:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l3kdC-000205-Ed for bug-gnu-emacs@gnu.org; Sun, 24 Jan 2021 14:01:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Konstantin Kharlamov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 24 Jan 2021 19:01: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.16115148427656 (code B ref 45200); Sun, 24 Jan 2021 19:01:02 +0000 Original-Received: (at 45200) by debbugs.gnu.org; 24 Jan 2021 19:00:42 +0000 Original-Received: from localhost ([127.0.0.1]:37275 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l3kcs-0001zQ-9E for submit@debbugs.gnu.org; Sun, 24 Jan 2021 14:00:42 -0500 Original-Received: from forward106j.mail.yandex.net ([5.45.198.249]:35443) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l3kcq-0001zA-42 for 45200@debbugs.gnu.org; Sun, 24 Jan 2021 14:00:41 -0500 Original-Received: from iva3-3aa7bbf53bdf.qloud-c.yandex.net (iva3-3aa7bbf53bdf.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:4983:0:640:3aa7:bbf5]) by forward106j.mail.yandex.net (Yandex) with ESMTP id E1EA711A0D7F; Sun, 24 Jan 2021 22:00:32 +0300 (MSK) Original-Received: from iva8-174eb672ffa9.qloud-c.yandex.net (iva8-174eb672ffa9.qloud-c.yandex.net [2a02:6b8:c0c:b995:0:640:174e:b672]) by iva3-3aa7bbf53bdf.qloud-c.yandex.net (mxback/Yandex) with ESMTP id 4G3T6JmRog-0WG0OMjd; Sun, 24 Jan 2021 22:00:32 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1611514832; bh=bHettI+ZzAnUuZGNz0T0xIOWtjvdJd8nsWDkhcqJBME=; h=In-Reply-To:Cc:To:From:Subject:Message-ID:References:Date; b=DVYwPw1989BZeEJfI33lXl3+PR2T18S59740qPN4+9m4Yd/5RinU/jKibkPtteTaD iy2fhR15/HGSHMGuBVL/MRy0ODPsVhJzFbakWZDX+Pe57Wqg4O4Ey3sIMeixXwpJaF le8/KoGt8aezRBXkvJLoBQXeH0vurZRz/f2HsKaI= Authentication-Results: iva3-3aa7bbf53bdf.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Original-Received: by iva8-174eb672ffa9.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id r3NgoBo7Lp-0WImEXdo; Sun, 24 Jan 2021 22:00:32 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) In-Reply-To: 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:198513 Archived-At: On Sun, 2021-01-24 at 13:51 -0500, Stefan Monnier wrote: > > # Steps to reproduce: > > > > 1. Run `mkdir /tmp/.emacs.d` > > 2. Run emacs as `HOME=/tmp/ emacs`, and measure its PSS > > 3. Create a file /tmp/.emacs.d/early-init.el with content: > > > >     ;; only run garbage collection on idle > >     (setq gc-cons-threshold most-positive-fixnum) > >     (run-with-idle-timer 2 t (lambda () (garbage-collect))) > > > > 4. Run emacs as `HOME=/tmp/ emacs`, evaluate (garbage-collect), then measure > > its PSS > > > > ## Expected > > > > Size has no statistically-significant difference, because in both > > cases we garbage-collected memory. > > I disagree with this expectation: it is perfectly normal for the amount > of memory allocated to the Emacs process to be left higher if you delay > the GC.  There are various reasons for that: > - fragmentation, of course.  Not much we can do about it short of using >   a moving collector. > - the desire to keep memory around rather than return it to the OS, >   under the assumption that we'll need it again soon. > > And it's not considered as a memory leak as long as that memory has > indeed been needed in the past and that future allocations can still > make use of it. I'm fine with Emacs possibly keeping a dozen of megabytes for personal use. The problem though is that the issue easily manifests itself in hundreds of megabytes, as can be seen with the testcase marked as "Message #11" in web-ui.