android finish() method doesn't clear app from memory

Daniel Benedykt picture Daniel Benedykt · Dec 29, 2009 · Viewed 48.6k times · Source

I have an activity and I call the finish() method and the activity is not cleared from memory.

After calling finish() , I see that the method onDestroy() is executed successfully (and I clear all my variables and stuff in there).

Should it be cleared from memory or its how android works? As I understand the LifeCycle of the Activity is finished.

And if it keeps the app in memory so it runs faster the 2nd time the user uses it, what kind of objects can I leave in memory to reuse? If I understand correctly, I am suppose to clear everything on onDestroy.

Answer

Romain Guy picture Romain Guy · Dec 31, 2009

Android keeps processes around in case the user wants to restart the app, this makes the startup phase faster. The process will not be doing anything and if memory needs to be reclaimed, the process will be killed. Don't worry about it :)