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: Sat, 12 Dec 2020 21:43:10 +0300 Message-ID: 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="34655"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.38.2 To: 45200@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 12 20:57:18 2020 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 1koB13-0008tA-Ns for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 12 Dec 2020 20:57:17 +0100 Original-Received: from localhost ([::1]:43034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koB12-00040F-Ns for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 12 Dec 2020 14:57:16 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ko9sA-0004ij-Ui for bug-gnu-emacs@gnu.org; Sat, 12 Dec 2020 13:44:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34961) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ko9sA-0002lN-MZ for bug-gnu-emacs@gnu.org; Sat, 12 Dec 2020 13:44:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ko9sA-0000v6-Cf for bug-gnu-emacs@gnu.org; Sat, 12 Dec 2020 13:44: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: Sat, 12 Dec 2020 18:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 45200 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16077986033480 (code B ref -1); Sat, 12 Dec 2020 18:44:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Dec 2020 18:43:23 +0000 Original-Received: from localhost ([127.0.0.1]:46507 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ko9rX-0000u4-73 for submit@debbugs.gnu.org; Sat, 12 Dec 2020 13:43:23 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:38118) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ko9rV-0000tw-UO for submit@debbugs.gnu.org; Sat, 12 Dec 2020 13:43:22 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ko9rV-0003wd-I9 for bug-gnu-emacs@gnu.org; Sat, 12 Dec 2020 13:43:21 -0500 Original-Received: from forward106p.mail.yandex.net ([77.88.28.109]:57409) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ko9rS-0002Tr-D0 for bug-gnu-emacs@gnu.org; Sat, 12 Dec 2020 13:43:20 -0500 Original-Received: from mxback9g.mail.yandex.net (mxback9g.mail.yandex.net [IPv6:2a02:6b8:c03:7aa:0:640:d10:d80f]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 73FF11C816EE for ; Sat, 12 Dec 2020 21:43:11 +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 mxback9g.mail.yandex.net (mxback/Yandex) with ESMTP id ZktHbZDohB-hBlKKG4K; Sat, 12 Dec 2020 21:43:11 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1607798591; bh=oxv1AY/uOWizwjT7CWACUwRcNqxVlyMGswP6MDIAXkE=; h=To:From:Subject:Message-ID:Date; b=fvJ37UX4cPhGpjoZHd1jmR4+Q/RJTiOLQLEnkgzTqS2kWOgqFYZuXlEPQb/74VlAw JBWnzEARCupotd5Pjt0VPnpVIAPZKSetO1H1ChSmbkkb4uJVgFdW+8G2cKYGoDsgGb R2E1n3mZhyriGoDP/rYPHKORu07AjMCIZ+aozkeY= Authentication-Results: mxback9g.mail.yandex.net; dkim=pass header.i=@yandex.ru Original-Received: by iva8-174eb672ffa9.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id XHIvb3LCoV-hAI0l86g; Sat, 12 Dec 2020 21:43:10 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Received-SPF: pass client-ip=77.88.28.109; envelope-from=hi-angel@yandex.ru; helo=forward106p.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:195882 Archived-At: The problem is basically: (garbage-collect) refuses to collect some of the memory. It is more visible if you delay garbage collection, which is what I do for for performance-related reasons. My config has the following snippet: ;; only run garbage collection on idle (setq gc-cons-threshold most-positive-fixnum) (run-with-idle-timer 2 t (lambda () (garbage-collect))) How much memory gets lost depends on configuration. For me right after start the difference is 40 MB: ≈60 MB is Emacs PSS size without above code, and ≈100 MB it is when garbage-collection is delayed, *after* I run explicitly (garbage-collect). It is less visible without any other configs, nonetheless it's visible. # 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. ## Actual Size without calling explicit garbage-collect, from 3 runs, varied around 41.2..41.7 MB. Size afterwards, also 3 runs, varied around 45.4..45.5 MB. This is 4 MB lost. While not much, but as I mentioned it grows as much as to 40MB. The Emacs whose emacslient I'm using to write this email has size 218 MB, and now I wouldn't be surprised if much of that is actually a leaked memory. # Version Emacs-git 28.0.50, build from commit abd15e088e99