Ted
Ted

Reputation: 3

Android - process life cycle?

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?

Upvotes: 0

Views: 1942

Answers (1)

Matt Ball
Matt Ball

Reputation: 359816

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

Upvotes: 2

Related Questions