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.
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 :)
Best way is firstly use finish()
and after that use System.exit(0)
to clear static variables. It will give you some free space.
A lot of applications leave working processes and variables what makes me angry. After 30 minutes of using memory is full and i have to run Task Manager - Lvl 2 clear memory
Its not true that is cousing problems i've tried it for over 3 years in my apps. Never get crashed or restart after using Exit()
Try using
System.exit(0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With