Killing is always the final step in the process of Android requesting an
process to terminate.  The question is when does Android just kill versus when
shuts down the process.  So:

*
https://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle
*
https://developer.android.com/reference/android/app/Service.html#ProcessLifecycle

That doc does not really address the issue of when onDestroy() is called
before the killing, but some notable bits:

* "If an activity is paused or stopped, the system can drop the activity from
memory by either asking it to finish, or simply killing its process. When it
is displayed again to the user, it must be completely restarted and restored
to its previous state."

* "If the service is currently executing code in its onCreate(),
onStartCommand(), or onDestroy() methods, then the hosting process will be a
foreground process to ensure this code can execute without being killed."

.hc

Michael Rogers:
> Maybe I'm misinterpreting the docs - I read the Process Lifecycle
> section as saying that a process may be killed (in the classic Linux
> sense of the word) at any time, but a process hosting a foreground
> activity or service will only be killed under desperate circumstances.
> 
> "Generally, only a few foreground processes exist at any given time.
> They are killed only as a last resort - if memory is so low that they
> cannot all continue to run."
> 
> According to the same section, a service is considered to be running
> in the foreground while executing onDestroy(). Since a process hosting
> a foreground service may be killed (under desperate circumstances), I
> take that to imply that onDestroy() is not guaranteed to complete
> before the hosting process is killed.
> 
> I agree that onLowMemory() would be a good place to shut down cleanly,
> as the docs say it will "generally" be called before killing
> foreground processes.
> 
> "While the exact point at which this will be called is not defined,
> generally it will happen when all background process have been killed.
> That is, before reaching the point of killing processes hosting
> service and foreground UI that we would like to avoid killing."
> 
> https://developer.android.com/reference/android/app/Application.html#onLowMemory%28%29
> 
> Cheers,
> Michael
> 
> On 01/12/14 14:52, Hans-Christoph Steiner wrote:
> 
>> I don't see the particular thing you're referencing in the
>> Lifecycle page. One notable time when apps are killed without
>> warning is during an upgrade or removal.
> 
>> My understanding of the normal lifecycle is that Activities and
>> Services are always shutdown using the whole sequence (onPause(),
>> onStop(), onDestroy() etc.) before being killed.  Maybe that's
>> based on my wishful thinking.
> 
>> One thing to help tracking low memory conditions is creating
>> onTrimMemory() and onLowMemory() in an Application subclass.
>> Android should call those when memory is getting low as the first
>> step before killing things.  That's how I understand it at least.
> 
>> .hc that's Michael Rogers:
>>> Sorry if I'm misunderstanding the issue, but hasn't it always
>>> been possible for a service (even a foreground service) to be
>>> killed by the system without any methods being called?
>>>
>>> https://developer.android.com/guide/components/processes-and-threads.html#Lifecycle
>>>
>>>
>>>
> Cheers,
>>> Michael
>>>
>>> On 01/12/14 08:14, Hans-Christoph Steiner wrote:
>>>
>>>> Is there any documentation about onDestroy() no longer being 
>>>> called?  That would be a pretty big change.  Maybe something
>>>> in TorService is crashing? Then onDestroy() wouldn't be
>>>> called.
>>>
>>>> .hc
>>>
>>>> Nathan of Guardian:
>>>>> I think we've finally gotten all the background service
>>>>> longevity sorted out, especially on Lollipop where it seemed
>>>>> to be much more brutal, in outright killing of the TorService
>>>>> instant, even without calling onDestroy(). Anyhow, now
>>>>> startForeground() is doing what it should be, we aren't
>>>>> binding any more (Just use broadcasts and startService()
>>>>> calls), and Orbot doesn't show up in recent apps anymore, so
>>>>> no more swiping away....
>>>>>
>>>>>
>>>>> /** 14.1.4 / 29-Nov-2014 / 
>>>>> b7fcbdc4e85071191cc95c3824e7b5a90d36d1e8 **/
>>>>>
>>>>> * Stop background service being killed 1e0f640 adding 
>>>>> dummyactivity to stop task/broadcast from killing foreground 
>>>>> service ec9204a clean-up of code to make service more
>>>>> long-lived and stable da4866c update polipo to latest head
>>>>>
>>>>> * Activity and theme updates 917cfa1 support SDK 16, add
>>>>> custom theme, make Orbot singleTop activity 91f4fa0 cleanup
>>>>> landscape layout ad7d92f clean-up / remove un-used code
>>>>> d5823e3 updates to layout to make it cleaner 2d6c26a show
>>>>> exit node info in log
>>>>>
>>>>> APK Lollipop: 
>>>>> https://guardianproject.info/releases/Orbot-v14.1.4-LollipopPIE.apk
>>>>>
>>>>>
>>>
>>>>>
> (.asc)
>>>>> APK <= KitKat: 
>>>>> https://guardianproject.info/releases/Orbot-v14.1.4-UpToKitKat-nonPIE.apk
>>>>>
>>>>>
>>>
>>>>>
> (.asc)
>>>>>
>>>>> Souirce: 
>>>>> https://gitweb.torproject.org/orbot.git/commit/b34d971193d843f1258904cba55779a58c819d0f
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>>>>
> _______________________________________________
>>>>> Guardian-dev mailing list
>>>>>
>>>>> Post: [email protected] List info: 
>>>>> https://lists.mayfirst.org/mailman/listinfo/guardian-dev
>>>>>
>>>>> To Unsubscribe Send email to: 
>>>>> [email protected] Or visit: 
>>>>> https://lists.mayfirst.org/mailman/options/guardian-dev/hans%40guardianproject.info
>>>>>
>>>>>
>>>>>
>>>
>>>>>
> You are subscribed as: [email protected]
>>>>>
>>>
>>>
>>>
>>>> _______________________________________________ Guardian-dev 
>>>> mailing list
>>>
>>>> Post: [email protected] List info: 
>>>> https://lists.mayfirst.org/mailman/listinfo/guardian-dev
>>>
>>>> To Unsubscribe Send email to: 
>>>> [email protected] Or visit: 
>>>> https://lists.mayfirst.org/mailman/options/guardian-dev/michael%40briarproject.org
>>>
>>>>
>>>>
> You are subscribed as: [email protected]
>>>
>>>
> 
> 

-- 
PGP fingerprint: 5E61 C878 0F86 295C E17D  8677 9F0F E587 374B BE81
https://pgp.mit.edu/pks/lookup?op=vindex&search=0x9F0FE587374BBE81

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Guardian-dev mailing list

Post: [email protected]
List info: https://lists.mayfirst.org/mailman/listinfo/guardian-dev

To Unsubscribe
        Send email to:  [email protected]
        Or visit: 
https://lists.mayfirst.org/mailman/options/guardian-dev/archive%40mail-archive.com

You are subscribed as: [email protected]

Reply via email to