简体   繁体   中英

android “force close” what exactly happen with memory

I have few services in my application. Application is running in "android.uid.system" process. When I click "force close" then logs says :

Force stopping package com.sec.ims.android uid=1000 Force stopping service ServiceRecord{42b9a948 ... .....

I see that for each service running under my application. There in no onDestroy() call at all. I am wondering what exactly android is doing after "force close" ? Stopping whole process or just stopping all services, activities working under application ?

Do you know what happen with objects, static variables and threads which were created by those services ? Does android erase all memory heap for this application ?

A Force Stop will kill the VM (Virtual Machine) in which the application is running. All Objects, Services, and activities are killed.

It depends how you started the service.

Using startService() overrides the default service lifetime that is managed by bindService() .

When startService() is used, your service life-cycle remains when the original Activity is closed.

In both cases Android stops the services when memory is needed.

I think. This problem is low memory killer running problem. Android PF have kill alive process when heigher priority process need heap.

[ps]

  • if you create Low Memory Killer situation on purpose. I recommend that you use following my application. http://kyorohiro.blogspot.jp/2013/02/inside-kyorostress-1-produce-low-memory.html

  • if this issue is Low memory Killer problem, your service and process will be restarted . but your application 's data is erased in java heap.

  • if PF restart your process. then call onCreate().

  • Service lifesycle is changed operation by onStartCommand 's return value. check android api refernce.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM