Reputation: 287
How can we reclaim resource of activity on destroy?? Is is possible that we delete Activity from memory and reclaim resource immediately? How to free Ram resource in Android ?? I know how to kill an application using Process.killProcess(Process.myPid()) and reclaim resource but i wanted this for application having multiple activity and we delete only single activity from memory..
Upvotes: 0
Views: 1096
Reputation: 1006604
How to reclaim memory of single activity on destroy?
So long as you are not holding onto the activity via some static reference (e.g., static data member, background thread, etc.), the activity will be eligible for garbage collection after onDestroy()
completes. If you are concerned that perhaps you are indeed preventing your activity from being garbage collected, use MAT to try to determine what is keeping it around.
Is is possible that we delete Activity from memory and reclaim resource immediately?
No, no more than you can "delete" anything in a garbage-collected runtime environment.
How to free Ram resource in Android ?
Let go of the "Ram resource" when you no longer need it, and it will be garbage collected.
I know how to kill an application using Process.killProcess(Process.myPid())
Please don't do that.
Upvotes: 2