On Tue, Aug 10, 2010 at 10:55 AM, doug <doug_a...@yahoo.com> wrote:

> "...so the system keeps them running unless there's not enough memory
> to retain them along with all foreground and visible processes".
>
> But are you implying that OutofMemoryError will not occur *before* a
> service is killed in a low memory situation?  In other words, an
> OutofMemoryError  will occur *only* when my own service eats up all
> the 16 MB default heap size.  Then I don't need to worry about another
> service/activity squeezing the 16MB heap size.  Is that true?
>

OutOfMemoryError and Android's background process killing are completely
separate things.  OutOfMemoryError is all about you running out of space in
your own app's heap; process killing is the policy for removing old
processes as memory is needed elsewhere.

If there is not enough memory globally to keep your service running, the
system is under duress, it needs to kill you now, and it won't give you a
chance to do anything about it.  (Actually that's not entirely true -- these
days we fairly regularly kill services if they have been running in the
background for a long time, to just avoid things like memory leaks from
negatively impacting the system.  In either case, though, your service will
be automatically restarted if that is the behavior it wants.)

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

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

Reply via email to