This question has been deleted and is no more available to answer.
2
Let say I have ActivityOne that is showing some videos, images etc. Now let say i am moved to ActivityTwo, so what happens to the memory that is occupied by the ActivityOne and its resources? Is it still hold the place in the memory or Android OS temporary removes it and recovers it back when the user navigate back, or should i manually manage the memory in that case? Thanks!!!

Share using link:

Direct share:

Aug 7 at 7:35:47
Jude
Jude
476

no need to do such memory management, its automatically handled by underlying os.Alex Reado Aug 7 at 7:50:29

1 Answer

2
I will answer your question by first quoting your questions you asked in explanation.

Is it still hold the place in the memory?

Yes, as soon as the activity is live either it is in foreground or not, its memory is still stable. Nothing got removed from the device memory until you finish the activity by yourself when moving from that activity.

Android OS temporary removes it and recovers it back when the user navigate back?

No, there is not such thing in Android OS which will remove the activity once its not in foreground and recovers it back when you go back to that activity.

Should i manually manage the memory in that case?

It is possible but it is complicated process to implement such system in your android app and even to achieve this thing you would have to go for extra overhead when the activity to which you are going back will become slow because of course you will get the images, videos etc back at the beginning of the activity when the activity is not on the foreground, so it can slow down the performance at that point.

Summary:

Its better to leave it on the Android OS, i am agree Android OS is not human but it knows well than the human beings, but the most important thing you should also consider is you should optimize your script, use less resource consuming components like RecyclerView etc, for example. Its my suggestions now its up to you.

Almost same question is also asked on SOF, you can read it here:
Android memory management in activity lifecycle
Aug 7 at 7:47:21
Yellow
Yellow
391

Nice explanation. Thanks!!!Jude Ak Aug 7 at 7:49:40

Asked
4 months ago
Viewed
99 times

Previously Asked