No, it will never be true. The VM doesn't manage processes at all. The system starts a process and runs a VM inside of it when it needs to run any components of an application. Unless you specify otherwise, all of your components run in the same VM, in the same process, sharing all of the same statics.
There is really nothing special about this besides a normal operating system. There are processes, these are managed by the kernel, and they run some code. There is Dalvik, which is some code that can run in a process. It can't hop your code into another process. On Tue, Jul 14, 2009 at 2:59 PM, Richard Schilling < [email protected]> wrote: > > Yes. I had read that, and I understand that the VM tries to stratify > processes depending on their function and keep my process alive as > long as possible. What I'm really interested in is detecting when the > the VM (re)-instantiated and garbage collects my Activity class, and > how that relates to the process identifier... > > So, with this code, would procewssIDChanged ever be true? I know it's > a mundane question, but it tells me a lot about Android process > management.... > > > > public IfWeirdAlWasAProgrammer extends Activity{ > > private static boolean newInstance = true; > private static int currentProcessId = -1; > > private boolean processIDChanged = false; // non-static on purpose > > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > > if (newInstance){ > Log.i("WeirdAlWasHere", "Like a surgeon, cuttin' for the > very first tiiiiime."); > newInstance = false; > currentProcessId = android.os.Process.myPid(); > } > > if (!newInstance && (currentProcessId != > android.os.Process.myPid()){ > processIDChanged = true; > Log.i("WeirdAlWasHere", "I lost on Jeapordy, baby! > Ohhhh!"); > } > > > } > } > > > > Thanks again. > > > > On Jul 14, 1:41 pm, Dianne Hackborn <[email protected]> wrote: > > Yeah, the process lifetime, which is outlined here: > > > > http://developer.android.com/guide/topics/fundamentals.html#proclife > > > > On Tue, Jul 14, 2009 at 1:38 PM, Richard Schilling < > > > > > > > > [email protected]> wrote: > > > > > Thanks Dianne. Very helpful indeed. > > > > > For process lifetime, I don't think you're referring to the "entire > > > lifetime" of an Activity as defined on the API reference page for > > > Activity (http://developer.android.com/reference/android/app/ > > > Activity.html< > http://developer.android.com/reference/android/app/%0AActivity.html> > > > ): > > > > > "The entire lifetime of an activity happens between the first call to > > > onCreate(Bundle) through to a single final call to onDestroy()". > > > > > Rather, you're referring to a broader lifetime of the process that > > > underlies the Activity.... correct? This would be the lifetime > > > associated with android.os.Process I assume.... > > > > > Richard Schilling > > > Root Wireless > > > > > On Jul 14, 1:23 pm, Dianne Hackborn <[email protected]> wrote: > > > > Statics are statics -- they are global to the process. So their > value > > > will > > > > last for the lifetime of the process, which is usually much longer > than > > > an > > > > individual activity instance. > > > > > > On Tue, Jul 14, 2009 at 12:52 PM, Richard Schilling < > > > > > > [email protected]> wrote: > > > > > > > I just ran into a situation where it looks like a static variable > > > > > reference is persisted across activity sessions. I didn't expect > that > > > > > because I thought that when an activity exits, it's de-referenced > and > > > > > garbage collected. > > > > > > > I am wondering if anyone can shed some (more) light on when the VM > > > > > eliminates object references for Activities and Services and in > > > > > particular when static variables get reset to default values? > > > > > > > Thanks. > > > > > > > Richard Schilling > > > > > Root Wireless > > > > > > -- > > > > Dianne Hackborn > > > > Android framework engineer > > > > [email protected] > > > > > > Note: please don't send private questions to me, as I don't have time > to > > > > provide private support, and so won't reply to such e-mails. All > such > > > > questions should be posted on public forums, where I and others can > see > > > and > > > > answer them. > > > > -- > > Dianne Hackborn > > Android framework engineer > > [email protected] > > > > Note: please don't send private questions to me, as I don't have time to > > provide private support, and so won't reply to such e-mails. All such > > questions should be posted on public forums, where I and others can see > and > > answer them. > > > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

