MacOS – Can macOS be prevented from pausing an app when the system runs out of application memory

configurationforce quitmacosmemory

I sometimes run distributed computing projects in BOINC Manager while my iMac is idle. Often, a Force Quit dialog appears displaying the message 'Your system has run out of application memory'. When this happens, all open applications except the Finder are paused and have to be manually restarted, one-by-one, from the dialog box.

I could reduce the amount of RAM that BOINC Manager can use, but I’d prefer to allocate as much RAM as possible to BOINC projects. How can I prevent macOS from suspending BOINC (or any other app or apps) when the system runs out of RAM?

Update: this issue appears to have been fixed by a recent BOINC update.

Best Answer

You most probably do not want to avoid macOS from suspending apps when the system runs out of RAM when you know that the only alternative is to kill the program. I.e. stop the program from running now and here without saving its data or anything like that.

However, you do not have to restart the programs that are paused as in "close the program and start it over". Instead you can actually unpause the program when you have sufficient free memory on the system. You can do this from the terminal by running:

kill -CONT <pid>

where should be replaced with the process ID of the process, you want to unpause.

You can find process ID using Activity Monitor or the "ps" command in the Terminal (in this case, look for processes with status T as these are the paused/stopped ones).

An easy way of unpausing and finding the ID in one go is:

kill -CONT `pgrep myprogram`

where myprogram is the name of the program you want to unpause.

The second part of your question where you describe the ideal scenario is very hard to accomplish with a standard program. In general programs can request memory from the operating system, but the operating system cannot request it back afterwards. It is possible, but it requires very specialized programs which is generally not the case.

This means that once macOS have granted your program for example 1 GB of RAM, the operating system cannot just take it back when other programs want more memory. If you take away memory from programs that are not specially crafted to allow that, they will effectively crash as soon as they attempt to use the lost memory.