Subject: bug#43389: 28.0.50; Emacs memory leaks

From: Jean Louis <[email-masked]>
Date: Tue, 10 Nov 2020 22:51:16 +0300

* Eli Zaretskii <[email-masked]> [2020-11-10 18:47]:
> > Date: Tue, 10 Nov 2020 01:33:17 +0300
> > From: Jean Louis <[email-masked]>
> > Cc: Eli Zaretskii <[email-masked]>, [email-masked],
> >   Russell Adams <[email-masked]>
> > 
> > It was happening regularly under EXWM. Memory get occupied more and
> > more and more until it does not go any more, swapping becomes tedious
> > and computer becomes non-responsive. Then I had to kill it. By using
> > symon-mode I could see swapping of 8 GB and more. My memory is 4 GB
> > plus 8 GB swap currently.
> > 
> > This similar condition takes place only after keeping Emacs long in
> > memory like maybe 5-8 hours.
> > 
> > After putting laptop to sleep it happens more often.
> > 
> > When I changed to IceWM this happened only once.
> 
> If this was due to a WM, are you sure it was Emacs that was eating up
> memory, and not the WM itself?

More often I could not do anything. So I have just hard reset computer
without shutdown. For some reason not even the Magic SysRq key was
enabled on Hyperbola GNU/Linux-libre, so I have enabled that one to at
least synchronize disk data and unmount disks before the rest.

How I know it was Emacs? I do not know, I am just assuming. I was
using almost exclusively Emacs and sometimes sxiv image viewer which
exits after viewing and browser. Then I switched to console and tried
killing browser to see if system becomes responsive. Killing any other
program did not make system responsive, so only killing Emacs gave me
back responsiveness. Provided I could switch to console as
responsiveness was terrible. From maybe 20 times I could switch maybe
few times to console to actually get responsiveness.

This happened more than 20 times and I was using symon-mode to monitor
swapping. When I have seen that swapping is few gigabytes for no good
reason I have tried killing everything to understand what is going
on. I've end up killing Emacs and EXWM and restarting X to get into
good shape.

Because it was tedious over weeks not to be able to rely on computer
under EXWM, I have switched to IceWM which is familiar to me. And I
did not encounter anything like that regardless how long Emacs runs.

Now after discussion of other bug where you suggested limiting rss and
after limiting rss I could invoke ./a.out and get prompt, and maybe
that ulimit -m or other tweaking could stop that type of behavior. I
have to look into it.

It could be again that Emacs is not responsible for that but rather
liberal system settings.

> If it was Emacs, then I think the only way it could depend on the WM
> is if the WM feeds Emacs with many X events that somehow consume
> memory.

I was thinking to report to EXWM but I am unsure why it is happening
and cannot easily find out what is really swapping. But because I used
often Emacs exclusively that is how I know that it has to be Emacs
swapping.