Tuesday, September 27, 2011

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

There is no such thing as "application low memory" in this context.  Application being low on memory == getting OutOfMemoryException, period.  It doesn't impact activity lifecycle at all.

The "Low Memory: No more background processes" means that the activity manager has gotten to the point where all background processes have been killed, most likely because of low memory across the entire system.

If you have gotten this message, all processes in the background have been killed.  Including yours.

You will not have gotten any callbacks, your process is just killed.

(Note by this definition, no processes in the background will ever have onLowMemory() called because it is only called once all background processes are gone.)

If your process is not getting killed, the only reason is because it is not a background process.  This may be because it is running a service, for example.

A useful command line tools for looking at the state of processes and activities:

adb shell dumpsys activity

This shows the activity stack, with the state of each activity, including the process (if any) that its activity is running in.  It also gives a summary of all application processes and how they are being managed with the OOM killer.

On Mon, Sep 26, 2011 at 4:12 PM, Artem Russakovskii <archon810@gmail.com> wrote:
Hi SOB,

No, since according to the SDK docs, that function is supposed to run
on general OS low memory and not on application low memory. On a real
system, these will almost never coincide, unless my app happens to
overflow the OS to a low memory state.
http://developer.android.com/reference/android/app/Application.html#onLowMemory%28%29

However, I do get this in the log every time: INFO/
ActivityManager(61): Low Memory: No more background processes

This is kind of confusing, because the emulator shouldn't run out of
memory just because my app is getting close to its heap limit. These
are the kinds of things I'm confused about and looking to clarify
here.

On Sep 26, 3:36 pm, Streets Of Boston <flyingdutc...@gmail.com> wrote:
> Just for debugging purposes:
> Have you implemented the Activity's method 'onLowMemory()'  and put a
> debug/logcat statement in there to see it this one gets called or not?

--
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



--
Dianne Hackborn
Android framework engineer
hackbod@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.

--
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