thebnich
thebnich

Reputation: 33

What is holding my activity's state once my application process has been killed?

I've been testing the behavior of my program by running a memory-eating application that forces my application to be killed. After reading the answers to Where is the bundle of onSaveInstanceState saved?, I'm confused about some of the results I'm seeing.

Both answers given in that link imply that individual activities, not applications, are destroyed when memory needs to be reclaimed. But according to http://developer.android.com/guide/components/processes-and-threads.html, processes - not individual activities - are killed. And since all components usually run in the same process, I would expect the entire application to be killed in low memory situations. My testing is consistent with the Android documentation in that I no longer see the process running when I run my memory eating app.

So if the entire process is killed, am I correct in assuming that the answers given in that question are incorrect? But if so, what's keeping my Bundle around when I resume my application if the process was killed? Is it really guaranteed to never be written to disk?

Upvotes: 3

Views: 763

Answers (2)

crgarridos
crgarridos

Reputation: 9263

As today the documentation says that saved instance state is serialized to disk.

enter image description here

https://developer.android.com/topic/libraries/architecture/saving-states#options_for_preserving_ui_state

Upvotes: 1

CommonsWare
CommonsWare

Reputation: 1006914

Both answers given in that link imply that individual activities, not applications, are destroyed when memory needs to be reclaimed.

That is incorrect, though I was confused on this point for a long time myself.

IMHO, at most one of the three answers on that question "imply that individual activities, not applications, are destroyed when memory needs to be reclaimed".

But if so, what's keeping my Bundle around when I resume my application if the process was killed?

Sometimes, nothing is "keeping [your] Bundle around". Other times, a process central to the OS is "keeping [your] Bundle around".

Is it really guaranteed to never be written to disk?

Is not "guaranteed", insofar as it is not documented whether or not it is written to disk. If it is written to disk, it will be done so by an OS process (not yours), and the file should be unreadable by other processes.

Upvotes: 7

Related Questions