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.devel Subject: Re: Garbage collect and buffer-undo-list Date: Sat, 13 Mar 2021 14:01:24 -0500 Message-ID: References: <24DD7B5A-CD84-4D8B-A1D9-B7E4BA77DB1A@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28670"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Mar 13 20:02:43 2021 Return-path: Envelope-to: ged-emacs-devel@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 1lL9X8-0007M4-HB for ged-emacs-devel@m.gmane-mx.org; Sat, 13 Mar 2021 20:02:42 +0100 Original-Received: from localhost ([::1]:58238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lL9X7-00081y-JW for ged-emacs-devel@m.gmane-mx.org; Sat, 13 Mar 2021 14:02:41 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lL9W3-0007Ks-6M for emacs-devel@gnu.org; Sat, 13 Mar 2021 14:01:35 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:40106) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lL9Vw-0001H3-Vn for emacs-devel@gnu.org; Sat, 13 Mar 2021 14:01:34 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 2D84A4408BD; Sat, 13 Mar 2021 14:01:27 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id AE64C440837; Sat, 13 Mar 2021 14:01:25 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1615662085; bh=9K3elG1jDXXHMnBgjFVOn2LrU5KJdYKDiu4//6imCjo=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=KDbMv1qAJNI7HbHHz91KCMVg6ypCb5lsC6O5/ZSyk77u8cRCynWINRmdFmveaCkvM GqyLOSjBp8x1qeqDoDqtG8YInuB/19wudEg0GTxjDDlxUCbQdnBkdxMUouJFyc/EXh p6cmIcJ1WF1XaT/vci7prs4SEMvLzSAhv96ZdpMWdnwC112OnIYJRjubFd8CVHwc10 1G/szMBROh7T8LszKXwmmLcPOtdRT+wcbe9IBJz8InSFRFVbFz6WqCOoxwO/+XCvjM NZqj3vr2virwXqEhgwJiou/gisYuT2uvkoskT9AFF0kbjIDEcGNznbIIQpzN+lLiWx APgOKrF/E+Apw== Original-Received: from alfajor (unknown [216.154.43.249]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 47F101201DD; Sat, 13 Mar 2021 14:01:25 -0500 (EST) In-Reply-To: <24DD7B5A-CD84-4D8B-A1D9-B7E4BA77DB1A@gmail.com> (Yuan Fu's message of "Sat, 13 Mar 2021 13:17:28 -0500") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:266438 Archived-At: > I know the garbage collector trims buffer-undo-list. Does it collect the > cons cell if there are other references to that object (other than > buffer-undo-list)? No, it can't. If you want to keep a reference to some of those cons-cells but still want the GC to collect them when the undo-log is trimmed, then you need to use a weak reference. We don't currently have plain "weak references" in ELisp, but we do have hash-tables whose keys and/or values can be weak references (that's what I used in `undo-equiv-table`). Stefan