Question: Still confused on Processes and Tasks


This is a continued discussion on viewtopic.php?f=402&t=6512#p17792.

-Each process has Dalvik VM running.
-By default, my application is created with it own process. All components (activities, broadcast listeners, services, content providers, etc) of my application run on that process.

So far, so good. Make a common sense. If I write C/C++ programs, everything within that programs will be running on one process although we can spawn other processes and threads.

From page 384, “”" Every activity instance lives in exactly one process and in exactly one task. That is where similarities end, though. Tasks only contain all running code and objects in an application. It can be easy to confuse…"""

As you predicted, it is still not clear to me what are the real differences between Processes and Task. Understanding processes was easy. I assume they are mapped to native OS processes. What exactly Task is? Is it just OS level data structure to keep track of activities? If so, how do they keep track? Actually instantiating or referencin?

Sorry to bother you too much on this. Probably, I should do more research on my own. I just want to have an easy solution by piggy back on your experiences. :smiley:


No problem. It’s a common point of confusion.

You’ve caught on to the key point though - while to the user a Task may seem like a process on your desktop machine, in reality it is simply a set of Activities - or, to be very particular, a set of ActivityRecords, since Activities themselves are constantly coming to life and going away. These ActivityRecords and their Task associations live in the OS, so they don’t go away if/when your process happens to be killed.