Subject: Re: bug#31091: 25.2: Feature Request: auto exit upon memory exhaustion warning

From: Noam Postavsky <[email-masked]>
Date: Sun, 08 Apr 2018 09:25:06 -0400

Boruch Baum <[email-masked]> writes:

> As emacs begins to exhaust memory, it begins to grind all system process's
> performance to a halt, which is clearly undesirable. If the user notices
> in time, either because the user is attentive to the mode line or the
> system slow-down, then the user will have an opportunity to gracefully
> exit and restart emacs, but such is not always the case, and should not
> be presumed to always be the case.

If you set the virtual memory limit to 1 or 2 GB (or something
proportional to the amount of physical memory you have) by doing

    ulimit -Sv $((1000 * 1024))

before you start Emacs, instead of allocating until system slow-down,
Emacs should stop with a message:

    Memory exhausted--use C-x s then exit and restart Emacs

Possibly also a warning like

    Emergency (alloc): Warning: past 75% of memory limit

depending on how quickly you approach the limit.

(yes, I've tried this, see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26952#18)