Mark,Dianna: Sorry, light bulb just went on. I think this is what you're saying: - Currently, the Thread will hold onto just 1 old Activity. - With my solution, the Thread will hold onto 1 old Activity, then that Activity will then holds onto the next old activity, and the next, ... So if a thread starts, then the user decided to flip the screen 20 times, then that's 20 activities all held.
Yes, that would be a bit of a problem. On Aug 31, 9:10 am, CraigsRace <craig...@gmail.com> wrote: > Mark: Sorry, I deleted my original post (very rude, I know!), as I > decided to just go ahead and write a solution myself (see previous > post). > > As for starting multiple threads, yes, they will hold on to the old > Activities. However, that's what happens right now, no? In fact, > that's the whole problem, when the threads try to do UI, they are > referring to the old activities. > > On Aug 31, 8:26 am, Mark Murphy <mmur...@commonsware.com> wrote: > > > CraigsRace wrote: > > > I'm obviously missing something, as I thought the Thread would be the > > > only thing holding onto the old Activity (as it is now). When the > > > Thread dies, the old activity would be garbage collected (as it does > > > now). All forwarding would be done via the Activity class. > > > Correct, but what Ms. Hackborn wrote was: > > > >> And that still means it needs to keep the old activity around so the > > thread > > >> can use it. > > > So, given that, imagine this scenario: > > > -- Activity instance A starts > > -- You fork a background thread, holding onto A, that will run for 30 > > seconds, as a result of a button click > > -- At 0:02 into the thread, the user rotates the screen > > -- Android creates a new activity instance (B), and has A point to B for > > the purposes of your call forwarding stuff > > -- At 0:05 into the first thread, you fork another thread, holding onto > > B, that will run for 30 seconds, as a result of a button click > > -- At 0:07 into the thread, the user rotates the screen again (bear in > > mind that for non-QWERTY devices, it doesn't take much to cause the > > screen to rotate) > > -- Android creates a new activity instance (C), and has B point to C for > > the purposes of your call forwarding stuff > > > At this point, we have three total instances of the activity running (A, > > B, C), and we still have 23 seconds of the original 30 to work with. > > Factor in the possibility of developers having threads that run for 30 > > days instead of 30 seconds. > > > In your specific example, coded properly, the forwarding mechanism may > > work fine, if your thread is very short lived (a couple of seconds), > > won't get started again, and your activities are not terribly complex. > > It's when you start to violate those assumptions (coded improperly, > > lotsa threads, long threads, complex activities) that memory issues > > become more painful. > > > -- > > Mark Murphy (a Commons > > Guy)http://commonsware.com|http://twitter.com/commonsguy > > > Warescription: Three Android Books, Plus Updates, $35/Year > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---