all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Marcin Borkowski <mbork@mbork.pl>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: help-gnu-emacs@gnu.org
Subject: Re: When are unused overlays garbage collected?
Date: Thu, 27 May 2021 18:26:26 +0200	[thread overview]
Message-ID: <87v974cfd9.fsf@mbork.pl> (raw)
In-Reply-To: <jwvtumpo8tp.fsf-monnier+emacs@gnu.org>


On 2021-05-26, at 16:48, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

>> Thanks, too, this is pretty interesting.  I assume one possible reason
>> for not having `markers-in' (analogous to `overlays-in') is that an
>> overlay (even without any variable pointing to it, IOW, a "name" for it)
>> has some "semantics" (properties), so it can be "guessed" what it is
>> for; for markers, we would only know that "someone wanted to remember
>> this position, but we have no idea why/what for", so why even bother
>> keeping it?  (Technically, there is also the insertion type, but that
>> doesn't tell much, either.)
>
> There's been proposals to add a `markers-in` function or
> something similar.  The main motivation was to better preserve some
> marker's positions when replacing a chunk of text with another.
>
> But the need is not very compelling, and there are some technical
> issues, one of them being that internally overlays are contain two
> markers, so this would risk exposing those markers, making it possible
> for an overlay to have a start and an end in two different buffers.
> None of this is terribly difficult to solve, but compared to the
> usefulness it just doesn't seem worth the trouble.

I see.

>>> So it's OK to create markers are then forget about them, but it's not
>>> OK to create overlays and then forget about them: you need to manually
>>> `delete-overlay` when you're done with them otherwise they'll accumulate
>>> in the buffer.
>>
>> And that is probably the most important takeaway here - but it raises
>> another question.  If I create an overlay in some buffer, keep no
>> references to it, and then kill the buffer - is the overlay eligible
>> for GC?
>
> Yes, of course, there's nothing very unusual going here, really: when an
> overlay is placed in a buffer, it creates a reference from that buffer
> to the overlay, so the overlay is reachable as long as the buffer itself
> is reachable.

Right, I didn't say that it's unusual - I only wanted to clarify that
I don't need to e.g. bother with `remove-overlays' before killing the
buffer (unless I keep a reference to some of them, of course).

Thanks,

-- 
Marcin Borkowski
http://mbork.pl



  reply	other threads:[~2021-05-27 16:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-24  5:00 When are unused overlays garbage collected? Marcin Borkowski
2021-05-24  5:05 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-24  6:33   ` Marcin Borkowski
2021-05-24 12:27 ` Eli Zaretskii
2021-05-26  4:53   ` Marcin Borkowski
2021-05-26  7:23     ` tomas
2021-05-26 15:36       ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-05-26 16:52         ` tomas
2021-05-26 12:30     ` Eli Zaretskii
2021-05-27 16:20       ` Marcin Borkowski
2021-05-27 16:41         ` Eli Zaretskii
2021-05-28 19:38           ` Marcin Borkowski
2021-05-24 17:07 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-05-26  5:01   ` Marcin Borkowski
2021-05-26 12:34     ` Eli Zaretskii
2021-05-27 16:23       ` Marcin Borkowski
2021-05-26 14:48     ` Stefan Monnier
2021-05-27 16:26       ` Marcin Borkowski [this message]
2021-05-27 21:42         ` Stefan Monnier

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=87v974cfd9.fsf@mbork.pl \
    --to=mbork@mbork.pl \
    --cc=help-gnu-emacs@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.