From: "Ami Fischman" <ami@fischman.org>
To: emacs-devel@gnu.org
Subject: mode-line-eol-desc needs to use assoc, not assq
Date: Fri, 19 Dec 2008 23:11:31 -0800 [thread overview]
Message-ID: <9aa0cfde0812192311j60e4adcao46753f828bc6a52f@mail.gmail.com> (raw)
mode-line-eol-desc uses assq to look up desc in
mode-line-eol-desc-cache, but the key used is computed by
coding-system-eol-type which returns a vector sometimes. This results
in mode-line-eol-desc-cache growing without bounds over the lifetime
of an emacs process. Changing mode-line-eol-desc to use assoc instead
of assq (so that the vectors are compared with equal and so have a
chance of returning t) fixes this.
Repro:
$ emacs -Q
eval (length mode-line-eol-desc-cache)
do this many times, the value is always 1.
eval (prefer-coding-system 'utf-8-emacs)
eval (length mode-line-eol-desc-cache)
do this many times; the value keeps increasing by 1 on every call(!).
C-h v mode-line-eol-desc-cache RET
eval (length mode-line-eol-desc-cache)
witness the returned value increasing by 3 for every C-h v
(describe-variable) as above.
Many innocuous actions such as visiting files and creating buffers
will cause this variable to grow with many many duplicate entries.
Drive the variable arbitrarily high by evaling:
(progn
(dotimes (j 1000)
(switch-to-buffer "does-not-exist")
(kill-buffer)
(redisplay))
(insert (format "%d " (length mode-line-eol-desc-cache))))
In an emacs running for several days I've seen the variable get over
420,000 entries in it, according to prin1-to-string.
Making the s/assq/assoc/ change as above fixes all these repro cases.
-a
next reply other threads:[~2008-12-20 7:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-20 7:11 Ami Fischman [this message]
2008-12-20 7:20 ` mode-line-eol-desc needs to use assoc, not assq Chong Yidong
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9aa0cfde0812192311j60e4adcao46753f828bc6a52f@mail.gmail.com \
--to=ami@fischman.org \
--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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).