Subject: Re: bug#27498: 25.2; Memory leak in M-x shell

From: [email-masked]
Date: Mon, 26 Jun 2017 08:01:14 -0400

forcemerge 26952 27498
quit

Ricardo Wurmus <[email-masked]> writes:

> Emacs leaks memory as lines are printed in a shell buffer.  Here is a
> recipe:
>
>     emacs -Q
>     M-x shell
>     yes "This should not leak, but it does."
>
> Observe the memory usage grow in a tool like “top”.  Once you decide
> that Emacs has eaten enough memory, kill the shell buffer.  Note that
> memory is not released.
>
> This is a problem for me because I often compile software in shell
> buffers (via “guix build”).  The compilation processes often print out
> very large amounts of text and Emacs quickly eats up all memory on my
> machine, freezing it.  I can only recover from this by killing Emacs
> (which is terrible, because I live in Emacs).

This is Bug#26952, it's due to using the custom "GNU version of malloc"
without the "relocating allocater" (there were several bugs with the
relocating allocater in 25.1).  To fix you can configure with
REL_ALLOC=yes (this should be okay in 25.2), or use Emacs' master branch
where the standard system allocater can be used once again.