开发者

Android - process life cycle?

开发者 https://www.devze.com 2023-04-03 14:23 出处:网络
I know everything about activity life开发者_高级运维 cycles, but what about the process itself? There\'s many projects which use the singleton pattern, where the Application class is extended to hold

I know everything about activity life开发者_高级运维 cycles, but what about the process itself? There's many projects which use the singleton pattern, where the Application class is extended to hold static objects.

Do these objects ever get destroyed? If so, when? Is there any documentation on this?


Do these objects ever get destroyed?

Yes, of course.

If so, when?

When the Android system kills the process because memory is low, and needed for other processes.

Is there any documentation on this?

Right here:

The Android system attempts to keep application process around for as long as possible, but eventually will need to remove old processes when memory runs low. As described in Activity Lifecycle, the decision about which process to remove is intimately tied to the state of the user's interaction with it. In general, there are four states a process can be in based on the activities running in it, listed here in order of importance. The system will kill less important processes (the last ones) before it resorts to killing more important processes (the first ones).

0

精彩评论

暂无评论...
验证码 换一张
取 消