Subject: Re: bug#43406: Emacs 27.1 memory consumption grows indefinitely

From: Ludovic Courtès <[email-masked]>
Date: Tue, 15 Sep 2020 16:19:55 +0200

Hi!

Ludovic Courtès <[email-masked]> skribis:

> Since I upgraded to Emacs 27.1, its memory consumption grows without
> bounds, to the point that it gets OOM-killed after just a couple of
> hours (meaning that it’s used most of the 16G of RAM of my laptop!).
>
> Does that ring a bell to anyone?  I have 50+ ^emacs- packages in my
> profile; any clues on what could be the cause before diving further?
>
> $ guix package -I ^emacs$
> emacs   27.1    out     /gnu/store/ipgb6s3phz3n740xlcdzaxnbgvncdh11-emacs-27.1
> $ guix describe
> Generacio 157   Sep 10 2020 08:49:21    (nuna)
>   guix 7090159
>     repository URL: https://git.savannah.gnu.org/git/guix.git
>     branch: master
>     commit: 7090159c23d6345992ab976d71fefeb1583cfcdf

Emacs is about to crash :-), so let me share this finding from
M-x profiler-report (mem) on a sample of a few minutes:

--8<---------------cut here---------------start------------->8---
- timer-event-handler                                     805,671,418  87%
 - apply                                                  804,987,874  87%
  + helm-ff--cache-mode-refresh                           802,103,698  86%
  + emms-playing-time-display                               1,349,461   0%
  + battery-update-handler                                  1,109,005   0%
  + #<compiled 0x1ff1153b5547>                                221,094   0%
  + #<compiled 0x1ff11537c089>                                 49,632   0%
  + blink-cursor-start                                         30,368   0%
  + auto-revert-buffers                                        29,480   0%
  + highlight-symbol-temp-highlight                            22,076   0%
  + mouse-avoidance-fancy                                      20,440   0%
  + display-time-event-handler                                 18,383   0%
  + show-paren-function                                        13,464   0%
  + erc-server-send-ping                                        7,500   0%
    jit-lock-force-redisplay                                    4,136   0%
  + blink-cursor-timer-function                                 4,136   0%
  + nnimap-keepalive                                            2,400   0%
  + gnus-demon-run-callback                                     1,545   0%
  + isearch-lazy-highlight-start                                1,056   0%
 + timer-activate                                             306,016   0%
 + timer-inc-time                                             191,264   0%
 + timer-activate-when-idle                                    92,928   0%
+ command-execute                                         100,936,674  10%
+ erc-server-filter-function                                5,178,272   0%
+ redisplay_internal (C function)                           4,988,306   0%
--8<---------------cut here---------------end--------------->8---

It’s Helm eating memory at each timer tick.  That’s with:

--8<---------------cut here---------------start------------->8---
emacs-helm-wikipedia	0.0.0-1.126f044	out	/gnu/store/iy08rcx4hbravm9k3qlinc4wvklp3pqi-emacs-helm-wikipedia-0.0.0-1.126f044
emacs-helm-swoop	3.0.0	out	/gnu/store/qnr6asnk0b360ilx8cnrp35kwrh4fsf7-emacs-helm-swoop-3.0.0
emacs-helm-shell-history	0.1-1.110d3c3	out	/gnu/store/ljgfa72mw8jx6br9khl7idcmrw4i33hc-emacs-helm-shell-history-0.1-1.110d3c3
emacs-helm-make	0.1.0-1.feae8df	out	/gnu/store/lnizl47zxlj03waficpy7fvfrx1mdqn7-emacs-helm-make-0.1.0-1.feae8df
emacs-helm-ls-git	1.9.1-1.76654c7	out	/gnu/store/897fkkh4bzpvbd06kf7vxr53hgkk0vfs-emacs-helm-ls-git-1.9.1-1.76654c7
emacs-helm-gtags	1.5.7	out	/gnu/store/lhibi05hvvn3zglcx2ii44yw723pfyja-emacs-helm-gtags-1.5.7
emacs-helm	3.6.5	out	/gnu/store/ka9lph0hpzaky0sa52zf09469apkhb68-emacs-helm-3.6.5
emacs-helm-system-packages	1.10.1-1.6572340	out	/gnu/store/lvkan5dsbcdkvl3y1fjmsgb423nzmmqc-emacs-helm-system-packages-1.10.1-1.6572340
emacs-helm-emms	1.3-3.37e5aa0	out	/gnu/store/g06lnxvyqnp9d2yqgfanp69350f7m2yp-emacs-helm-emms-1.3-3.37e5aa0
--8<---------------cut here---------------end--------------->8---

Cc’ing a couple of people who I think use Helm and hopefully have
valuable advice to share.  :-)

Ludo’.