Monday, September 26, 2011

[android-developers] Activities aren't getting killed by ActivityManager when app is running out of memory

Hi,

I've been battling this issue
http://stackoverflow.com/questions/7536988/android-app-out-of-memory-issues-tried-everything-and-still-at-a-loss
for the past couple of days, and at this point, either I don't
understand how Android works anymore, even after reading all the docs,
or I still have a bug that prevents activities from getting killed
when the process starts to run out of memory.

If my understanding is correct, if you have an app like Facebook and
you navigate it without ever clicking Back, the Android process could
eventually run out of memory. In this case, from what I'm reading,
Android would then start killing activities, specifically in onStop()
state. I'm not talking about total memory running low on the device,
I'm talking about getting close to the limit and risking the OOM
exception in the process itself.

I'm just not seeing this behavior. I simplified my app to the point
that I can just call the same activity 3-4 times in a row from itself
(using an Intent), and it will run out of memory and crash. I see each
activity enter onStop after the new activity starts, but I don't see
ActivityManager ever killing them. Instead, all I get are OOM. I watch
the heap grow and grow and never shrink back.

I got the activity itself in a pretty simple state too - a BaseAdapter
and a bunch of text in each cell, with the source of data about being
5,000 rows (just for testing - it doesn't take nearly this many to
crash when my simplifications are reverted). What I would expect to
happen in this test case is for the first instance of this Activity to
die as soon as memory in the heap starts getting low, but I'm not
seeing it.

Am I completely off base here? What am I missing?

Thank you.

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment