all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Yuan Fu <casouri@gmail.com>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Garbage collect and buffer-undo-list
Date: Sat, 13 Mar 2021 14:01:24 -0500	[thread overview]
Message-ID: <jwv4khe98yf.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <24DD7B5A-CD84-4D8B-A1D9-B7E4BA77DB1A@gmail.com> (Yuan Fu's message of "Sat, 13 Mar 2021 13:17:28 -0500")

> 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




  reply	other threads:[~2021-03-13 19:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-13 18:17 Garbage collect and buffer-undo-list Yuan Fu
2021-03-13 19:01 ` Stefan Monnier [this message]
2021-03-13 19:16   ` Yuan Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv4khe98yf.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=casouri@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.