How does the ActivityStack behave when it contains thousands of Activities?

by Scythe » Sun, 01 May 2011 02:31:44 GMT


Sponsored Links
 In my app I have a about a dozen of different Activities. These
Activities are connected (can call each other with startActivity()) in
such a way, that the user can theoretically keep running in circles -
always jumping to the next Activity, never going back. Also, I really
need to maintain a proper Activity history: if the user presses the
back button, the app returns to the previous Activity, with the
previous content.

Question: Suppose the user's using the app for an extended amount of
time, going in circles between Activites as mentioned above, resulting
an ever-growing ActivityStack. Every Activity saves some state on
onSaveInstanceState() too.

- Is this a problem? (I'm afraid it is, I guess it's a memory leak to
have tens of thousands of Activity records on the stack, especially if
these save their state).
- Is there a way to limit the size of the default Android
ActivityStack's size? (size limit is X, we delete the oldest record if
it gets filled up)

Any suggestions / alternative solutions are welcome.

-- 



Re: How does the ActivityStack behave when it contains thousands of Activities?

by Kumar Bibek » Sun, 01 May 2011 02:36:22 GMT


 You will perhaps run into stack overflows or oom.  Android will try to kill
some of your activities though when it finds necessary



-- 


Sponsored Links


Re: How does the ActivityStack behave when it contains thousands of Activities?

by Dianne Hackborn » Sun, 01 May 2011 04:17:44 GMT


 It doesn't.  Don't do that.  Allowing the user to keep cycling through
activities is fundamentally flawed.  Having an application that has more
than a handful of activities on the stack is not correct, both for the way
the system works and the user experience it causes.







-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

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.

-- 



Other Threads

1. JUNIT Tests results

Hi,

How to get the junit test results from eclipse to an XML or any
logfile?

Thanks,
Android user
--~--~---------~--~----~------------~-------~--~----~

2. OnTouchListener is not able to change ImageResource

I'm not sure offhand why this crashes, but it could be any number of
reasons...  If you could post the logcat output, that would be very helpful.

Also, I was wondering what you were trying to accomplish with this?  If you
are trying to change the image when a touch event occurs and then have it
change back when the touch event is done, you may want to consider using a
selector drawable instead...

It allows you to specify a single drawable that will change based on the
state of the object... i.e. onFocus, onPressed, etc....

I just barely figured out how to do that and there wasn't a whole lot of
documentation available.  If that is what you are trying to do I will post
again with how to do that...

Thanks,
Justin

----------------------------------------------------------------------
There are only 10 types of people in the world...
Those who know binary and those who don't.
----------------------------------------------------------------------






--~--~---------~--~----~------------~-------~--~----~

3. audio flinger :(

4. Getting stated

5. logcat api?

6. Too many PNGs in res/drawable?

7. Using a hyperlink to do something