$ emacs -Q M-x shell $ while true; do echo XXXXXXXX; done
Depending on how much RAM you have in total, wait for some reasonable amount. For instance, I'm typically waiting until the
shell buffer is around 5M lines and the corresponding memory consumption is around 5G.
It is indeed clear why it grows. However, when I kill the buffer, the amount of memory occupied by Emacs is still 5G. I'm aware of garbage collection (GC) and two variables
gc-cons-percentage, for which I tried different values without luck (including default). Waiting for some time does not seem to somehow lazily trigger any GC process either. Finally, even directly issuing
has no effect at all; the amount of occupied memory by Emacs remains at 5G and Emacs does not freeze even for a second to perform GC (which should definitely happen for such a large amount of memory).
Does anybody experience the same issue? I observe this on both 24 and 25 series. The reason why this issue has become really annoying lately is because I have to run many buffers tailing various continuously written logs, but killing any of these buffers does not seem to release the memory back. As a result, I simply run out of memory hourly, what forces me to quit Emacs and restart it to be able to continue work. What to do?
(setq-default garbage-collection-messages t)
does show the "Garbage collecting...done" messages in minibuffer continuously, what means that GC is indeed performed but, in fact, that confuses me even more. Why the memory is not released when the buffer is killed?