If your service only need to do work every 30 minutes, then it shouldn't be
left running all the time, just run based on scheduling an alarm.  Given
that, most of the time while your application is in the background there is
no service running in it so the system is free to kill the process and
everything in it if it needs more memory.  It is only while the service is
running that it won't.  And if you are starting the service and your app
process is already there, then it is more efficient to just launch the
service there rather than initializing a whole new process.

As a general rule, I would not run a service in another process unless you
have a clear way that this improves things.  The main way I can imagine is
if the service runs all of the time...  however (1) that is something you
really should avoid anyway, and (2) you may be better of just making sure
your activities release all of their heavy-weight resources when stopped to
allow your process to be GCed.

If your process consists of activities that hold 8 or more MB of data that
can't be GCed, and you have a service that runs all of the time, a good
argument could be made to have it run in another process.

On Mon, Jan 12, 2009 at 1:08 PM, iliketolearn <theand...@gmail.com> wrote:

>
> At one of the Android Google IO sessions, Dan Morrill mentioned that
> it would be rare to need to do so, without providing much more info.
> Also, the posts from Google/Android employees in this forum don't
> recommend doing this either, often citing "overhead." The official
> android documentation doesn't seem to grace this topic, and
> consequently I've been left with the same question: When would you
> need to put a service into a separate process?
>
> For my specific application, I need to communicate with a remote
> server every 30 minutes downloading some XML each time, dissecting it,
> and displaying notifications. I thought it would be a good idea to put
> this service in it's own process to completely separate it from the UI
> process. The reason being, the service process is a lot more light
> weight than the process with all my activities. It seems that it would
> be easier on the OS to keep the lighter service process constantly
> running/executing, and the OS could kill off the heavier process with
> all the activities when they aren't being used. Otherwise, if I put
> the service in the same process as the rest of my application, the
> system would need to keep this massive process (containing various
> views, activities, and a service) around continuously - something very
> inefficient. Is this the correct line of thinking? Or should I keep
> everything in 1 process?
>
> Thanks for your time.
> >
>


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