Subject: Re: bug#43389: 28.0.50; Emacs memory leaks

From: "Jose A. Ortega Ruiz" <[email-masked]>
Date: Wed, 18 Nov 2020 21:47:30 +0000

On Tue, Nov 17 2020, Eli Zaretskii wrote:

>> From: Florian Weimer <[email-masked]>
>> Cc: [email-masked],  [email-masked],  [email-masked]
>> Date: Tue, 17 Nov 2020 21:58:57 +0100
>> 
>> (let ((size 0))
>>   (dolist (buffer (buffer-list) size)
>>     (setq size (+ size (buffer-size buffer)))))
>> ⇒ 98249826
>> 
>> So it's not a small number, but still far away from those 800 MiB.
>
> Yes.  I have a very similar value: 94642916 (in 376 buffers; you have
> more than 1000).  This is in a session that runs for 17 days and whose
> VM size is 615 MB: a "normal" size for a long-living session, nowhere
> near 2GB, let alone 11GB someone reported.

As an additional datapoint, since version 27 (i usually compile from
master, so also before its release), i'm experiencing bigger RAM
consumption from my emacs processes too.  

It used to always be way below 1Gb, and at some point (i have the
impression it was with the switch to pdumper), typical footprints went
up to ~2Gb.  

In my case, there seems to be a jump in RAM footprint every now and then
(i get to ~1.5Gb in a day almost for sure, and 1.8Gb is not rare at
all), but they're not systematic.  

Everything starts "normal" (300Mb), then i open Gnus an it grows a bit
after reading some groups (500Mb, say), and so on, and be there for a
while even if i keep using Gnus for reading similarly sized message
groups.  But, at some point, quite suddenly, i see RAM going to ~1Gb,
without any obvious change in the libraries i've loaded or in my usage
of them.  The pattern repeats until i find myself with ~2Gb in N days,
with N varying from 1 to 3.

It's difficult for me to be more precise because i use emacs for
absolutely everything. But, perhaps tellingly, i don't use most of the
packages that have been mentioned in this thread (in my case it's ivy
instead of helm, i use pdf-tools and that has a considerable footprint,
but i see jumps without having it loaded too, similar thing for
emacs-w3m), and i see the jumps to appear so consistently that my
impression is that they're not directly caused by a single package.  

The only coincidence i've seen is that i use EXWM too (btw, that's a
window manager implemened in ELisp that makes emacs itself the window
manager, calling directly the X11 api through FFI), but other people are
having problems without it.

I've also tried with emacs compiled with and without GTK (i usually
compile without any toolkit at all) and with and without ImageMagick,
and the increased footprint is the same in all those combinations.  I
cannot see either any difference between the released 27.1 and 28.0.50
regularly compile form master: both seem to misbehave in the same way.

As i mentioned above, i've got a hunch that this all started, at least
for me, with pdumper, but i must say that is most probably a red
herring.

I hope this helps a bit, despite its vagueness.

Cheers,
jao

P.S.: I'm not copying the external GCC developers in this response
because i think most of the above makes only sense to emacs developers;
please let me know if you'd rather i did copy them.