Mac 911: Safari consistently quits in Yosemite
After leaving my computer for a period of time, I come back and Safari has closed down. No error or crash report, its as if someone is playing a trick on me and closes Safari. I have tried rebooting, deleting preference files, and turning off sleep. Not allowing my computer to sleep seems to have reduce the frequency that it happens, but I can't be sure of it.
In 10.7 Lion, Apple added an automatic background quit feature to OS X that's designed to better free up system resources by software that's not in use. It comes in two forms: automatic termination, which silently goes through the app's normal quitting process when you're not using it; and sudden termination, which kills off the app without any warning.
Both features require developers to add support, and Apple incorporated termination into many of its apps as an example to others. I notice that QuickTime Player, which I use to record audio from a mic, will quit sometimes almost immediately after I launch it if I navigate to another app before opening a new audio recording window! That's probably a bit aggressive.
However, this automatic quitting is supposed to be paired with faster startup, so that from the standpoint of user, they're not waiting for the app to launch again, but rather it seems a very brief pause before it's available.
I suspect this is what's happening with you and Safari, though it's clearly more aggressive than you want. I would also suspect that you typically have many apps running or not enough memory available for the apps you routinely use. OS X is quitting Safari whenever it has the opportunity to avoid using disk-based memory swapping, which slows down the system.
If you dare use the command line via Terminal, you can disable this behavior system wide. Enter exactly the following:
defaults write -g NSDisableAutomaticTermination -bool yes
Apps with the feature need to be quit and relaunched. Swap yes for no if you want to re-enable this feature later.
Ask Mac 911
We're always looking for problems to solve! Email yours to mac911@macworld.com including screen captures as appropriate. Mac 911 cannot reply to email or publish answers to every question.