I’m enabling Automatic Termination in my app. I added the NSSupportsAutomaticTermination key to my plist, and now I’m testing it out. Here’s what I notice, and I’d like to know if this is normal, or if there’s a problem (and what it might be).
- Launch the app
- Close its main (and only) window
- Switch back to Xcode
- Its icon disappears from the Dock
- Xcode’s status display still shows it as running, and I can even pause its execution
- After minutes, the status shows that it has finished running
Update
I’m not sure what to make of it, but I created a new project, the only change being added the above key to the plist, and it behaves the same way. I’ve also noticed that the app does indeed stay in Activity Monitor, but with 0% CPU. What does it all mean?
This intended behaviour (and has nothing to do with Xcode). Applications which support auto-termination are completely hidden, but kept running, when backgrounded without windows; this allows them to be “relaunched” instantly. It’s only done for auto-terminable apps because the system needs to be able to kill the process if system load increases. You can observe this behaviour with TextEdit (monitoring with Activity Monitor), for instance.
Auto-termination is sometimes called “automatic lifecycle management”, which is more accurate but a bit unwieldy.
For more information, see session 119 “Resume and Automatic Termination in Lion” from WWDC 2011, starting about 34 minutes in.