Subject: bug#79200: 31.0.50; Duplicated elements for '#<marker at' in buffer-undo-list

From: Óscar Fuentes <[email-masked]>
Date: Mon, 11 Aug 2025 22:54:19 +0200

Alan Mackenzie <[email-masked]> writes:

>> Why aren't they collected by GC?
>
> They are, eventually.
>
> But my hypothesis is that between GC runs many hundreds of useless
> markers clog up the buffer's list of markers, and these in turn clog up
> the OP's (Óscar's) undo list.
>
> And that if we could reduce the number of useless live markers we leave
> to GC, we could resolve the OP's problem.  It may even be that the vast
> numbers of markers we suspect get created are slowing Emacs down
> noticeably, though there's no firm evidence for this at the moment.

Since yesterday I'm running igc with 6f494d74f645d6c reverted, Pip's
detach_marker patch and this in .emacs:

(defun delete-markers-from-buffer-undo-list ()
  (when (sequencep buffer-undo-list)
    (setq buffer-undo-list
	  (cl-delete-if
	   (lambda (el) (and (consp el) (markerp (car el))))
	   buffer-undo-list
	   :end 500))))

(defvar delete-markers-from-buffer-undo-list-timer
 (run-with-idle-timer 3.0 t 'delete-markers-from-buffer-undo-list))

I'm aware that something like this can cause nasal demons, but so far no
ill effects observed.

I think Emacs/igc is using less memory than usual (in my past experience
at this time it should be well over 1GB, but it's stabilized on 0.8GB.)