Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android activity stack size problems?

I have an application with lots of activities. Many of these activities can start others, so the user's expected to generate a quite large activity stack.

I'm currently using the default activity launch behaviours. Does anybody know, if a large activity stack (like > 100) would be pose a problem? Is there a limit to this? Would it decrease performance, cause an ANR dialog, or something like that?

Thanks

like image 206
Zsombor Erdődy-Nagy Avatar asked Oct 14 '22 17:10

Zsombor Erdődy-Nagy


2 Answers

Android will kill Activities when it needs to to free up memory or other resources. Per the Activity Lifecycle, and Activity is eligible to be killed as soon as it is no longer visible.

Assuming you correctly handle the killing and restarting of Activities, you should be fine.

As an aside, I struggle to come up with a use case from a user's perspective where I would access > 100 activities in one app...

like image 148
Cheryl Simon Avatar answered Oct 29 '22 19:10

Cheryl Simon


Mayra's reasoning is wrong for this problem. Android kills activities from the stack as long as they are activities from a different application that the one currently running.

Therefore, if your application opens 100 activities, the 100 will be kept in the stack, and most probably you'll find OutOfMemoryError's.

Try to structure your app differently.

like image 45
alfongj Avatar answered Oct 29 '22 19:10

alfongj