Doug,
What I was getting at, is that Android has certain rules when killing
applications in a low memory situation, as well as mechanisms to keep
applications functioning.
- If your service needs to do work from time to time, on its own
schedule, set an Alarm using AlarmManager. Alarms are persistent, and
will fire even if the application that has set them has been killed.
- Android 2.0 introduced some changes in the Service API. If your
service uses Intents to perform on-demand work, use the new
START_REDELIVER_INTENT return value in onStartCommand, so that if the
service is killed and later restarted, it knows what it was doing before
getting killed.
http://android-developers.blogspot.com/2010/02/service-api-changes-starting-with.html
This will help your service restart and continue doing what it's
supposed to if it's killed.
On the other hand, an OutofMemoryError, I believe, is thrown when your
service tries to exceed the maximum heap size (16 or 24 MByte). This is
why I was suggesting you investigate why you're getting this exception.
-- Kostya
10.08.2010 21:55, doug пишет:
Thanks for the suggestions. What I was looking for is a defensive
programming technique to guard my service against memory exhaustion
caused by other services/activities running on the device. The SDK
has this to say about a service process:
"...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?
doug
--
Kostya Vasilev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en