Stop Task in Xcode vs. Quit Application

This might be more of an “any language” thing than just an ASOC thing, but it would probably apply the same to us, as well.

I discovered a while back when I was working with some NSTask operations that using “Stop Task” in Xcode (stop sign) works like Force Quit, which doesn’t run any “Terminate” notifications. In the case of tasks still running that were started with NSTask I’m OK with that. I’ve worked out a way to look for any previous tasks running and killing them upon restart, or killing them otherwise (Activity Monitor).

What I’m wondering about, though, are the other things that an app might do during normal Terminate operations (as coded in Terminate notifications). In particular, objects that are set up with alloc/init and normally released during a regular Terminate… Does all of this “live inside the app’s memory space”? Does all of this die and release memory back to the System in such a situation?

I understand there may be other consequences if we have open documents, files currently open, etc…, and I think I know what to look for in that regard.

It’s just that sometimes I’m reviewing my code while the app is running (usually checking out excessive log entries to watch what’s going on during development), I’ll make a change to my code and start another build/run, and it’ll inform me that my app is still running. Finding my app in the myriad of windows or locating it in my seriously over-crowded Dock is find, but it’s just so much quicker to kill and run… I just want to make sure that a force quit this way is generally safe.

I already thought that an application automatically releases any used memory on a quit, even a forced quit. But to be certain a made a little test utility in C:

Compile this with the following shell command and startup “Activity Monitor”. See what happens to the overall system memory usage when you start, quit or force quit the program.

gcc /path/to/file.c -out ~/Desktop/MemoryTest

The memory this program allocates has a size of 100MB. Just change the value if you want it to be more or less.

Hope it helps,
ief2