Reputation: 576
this is just a general question about android with no particular use case in mind. As I am currently still learning the platform, I have been doing some experimentation
with services.
I have created a class called TestService
that extends service. I have not made any changes to the code nor done anything inside the service. In essence, it is just an empty service. This is what I mean:
public class TestService extends Service {
@Override
public IBinder onBind(Intent intent) {
return null;
}
}
Using the following code, I start the service in my activity:
Intent sIntent = new Intent();
sIntent.setClassName("com.mytestapp.android.servicetest",
"com.mytestapp.android.servicetest.TestService");
startService(sIntent);
And to stop it, I call:
stopService(sIntent);
Now to monitor if my service is actually started, I accessed the running services list provided by android by going to Settings -> Applications -> Running Services. And well, it works.. the service shows up there.
One thing I have noticed, however, is that EVERYTIME i stop and start my service again, the memory used by the service seems to be INCREASING (as shown by the running services information). After doing it for about twenty times, the memory used by the service increased by almost 50% of the original!
I find this to be strange, and I'm wondering if anyone can explain what seems to be happening here? Is this normal?
Upvotes: 0
Views: 1177
Reputation: 1007658
Is this normal?
Most likely, those Service
objects have not been garbage collected yet.
Upvotes: 1