apps closing when display is put to sleep

Dear All,


I believe this question has already been asked but none of the answers were satisfactory, so I am going to try again. I would like to run a python code through terminal which will take several days. Therefore, I would like the hard disks to remain running while I put the display to sleep to save energy AND lock my computer so others can not get on while I am away from the computer. I have the following setting selected for Energy Saver (shown below). However, after some time, my computer still tries to close the terminal app. Last night, it did appear that the program continued to run but when I unlocked my computer this morning, I received a message indicating that the terminal had tried to close (again, see image below). How can I prevent this from happening while still putting my display to sleep and locking my computer?

iMac Pro

Posted on Aug 29, 2019 2:28 PM

Reply
Question marked as Top-ranking reply

Posted on Sep 5, 2019 6:35 AM

Hi All,


Thanks for your attempt at helping me. As I said, it is NOT a memory issue. It does not make sense that the memory would work differently when the display is off and locked than when the display is on.


I finally figured out what the issue was but I'm a bit flabbergasted by it. It is a very 'simple' fix but also very hard to find. If you go to System Preferences -> Security & Privacy then unlock so you can access the Advanced Settings under the General tab, there is an option to set "Log out after x minutes of inactivity". I have now unchecked this setting and am no longer having the issue.


This setting was very much hidden and not obvious. I don't know if the factory default of the new iMacs is set to log out after 30 minutes of inactivity or if the IT person who set up my computer in my office initiated this setting. If it is a factory default, it is extremely frustrating!


Anyway, I hope this thread helps someone else. I have included images of where to locate this setting.


Similar questions

9 replies
Question marked as Top-ranking reply

Sep 5, 2019 6:35 AM in response to BobHarris

Hi All,


Thanks for your attempt at helping me. As I said, it is NOT a memory issue. It does not make sense that the memory would work differently when the display is off and locked than when the display is on.


I finally figured out what the issue was but I'm a bit flabbergasted by it. It is a very 'simple' fix but also very hard to find. If you go to System Preferences -> Security & Privacy then unlock so you can access the Advanced Settings under the General tab, there is an option to set "Log out after x minutes of inactivity". I have now unchecked this setting and am no longer having the issue.


This setting was very much hidden and not obvious. I don't know if the factory default of the new iMacs is set to log out after 30 minutes of inactivity or if the IT person who set up my computer in my office initiated this setting. If it is a factory default, it is extremely frustrating!


Anyway, I hope this thread helps someone else. I have included images of where to locate this setting.


Aug 30, 2019 4:50 PM in response to aedmac

I am running the most recent released version of macOS (Mojave 10.14.6 plus all security updates). Killing an app is NOT a feature of the product, except if you run out of address space or disk space for virtual memory.


Do you have Scrollback set to "Limit to available memory"? If your script is generating lots and lots of output, that might be triggering the problem. And MrHoffman's suggestion to redirect your output to a file would be a way to deal with this:

Or setting the scrollback to a reasonable number of lines.

Aug 29, 2019 3:57 PM in response to aedmac

I live in Terminal sessions. My Terminal never tries to quit.


Now if you have an app like Quitter running and specified it should kill the Terminal after a period of time, or you have some other app that thinks it should kill apps, then Maybe.


Another possibility is if your program consumes all of your disk space and macOS cannot page or swap memory to disk anymore, or your process is becoming a virtual memory hog and causing macOS to use too much memory for virtual memory page tables, then I can see macOS trying to kill Terminal. But generally you get a message about being out of Application Memory.


Again, I have my work computer on 24/7, it never sleeps, and it has Terminal sessions running from right after being booted until it shutdown for macOS software updates that require a restart.


So I would be asking why you have running besides the Terminal and your Python script?


Try booting into Safe mode

http://support.apple.com/kb/ht1564

This will not load any 3rd party additions, it will load some more conservative Apple drivers (may cause screen flicker), and it will clear some kernel caches (a cache is saved data in a form that can speed up a program, but is totally redundant to the original source, and thus can be safely cleared).  Booting into Safe mode is just an experiment, but can frequently eliminate any 3rd party interference, or a cached item out-of-sync with the world.  (Verify Safe mode via Applications -> Utilities -> System Information -> Software -> Boot Mode -> Safe vs Normal)


You could also consider posting the EtreCheck output

<https://itunes.apple.com/app/etrecheck/id1423715984?ls=1&mt=12>

Click on the Share icon and select "Copy Report"

And then Paste the report as a "Reply" to this thread using an "Additional Text" box.

EtreCheck is a tool that helps Apple Support Community volunteers debug problems without any access to the troubled computers. Debugging problems can be a difficult task even when the machine is in front of you. Attempting it via a discussion forum is extremely difficult. EtreCheck is a great help that regards.

Aug 30, 2019 2:03 PM in response to BobHarris

Thanks, BobHarris, for the detailed response. This is basically a brand new iMac (bought one year ago). I have not loaded any programs such as Quitter onto it. So, unless this program (or one like it) comes pre-installed on the new iMacs, it should not be on my computer and should not be running. That's actually the main point of my question. My older Macbook Pro has no problem continuing to run even though I put the display to sleep and lock the computer. Thus, it is VERY strange that I am having this issue on a brand new iMac. My question then is: has Apple changed some setting or do new Macs now come with pre-installed software that will try to kill the terminal when the display is put to sleep and the computer locked? Is there some other setting than the ones I've indicated above that need to be adjusted? Any additional thoughts concerning new iMacs would be helpful. If I can't figure out what's going on within the next week, I'll look into your suggestion about EtreCheck.



Also, this is definitely not a memory allocation problem unless the memory acts differently when the display is put to sleep as opposed to when the display is on. The terminal never tries to close if the display is active.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

apps closing when display is put to sleep

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.