I have an activity which uses considerable amount of memory in my app. So whenever the user switches over from that activity to some other activity, I am trying to call finish() to stop that activity.
My question is, will calling finish() from that activity free up memory space or just finishes that activity without cleaning the memory used by that particular activity?
Any help is much appreciated..
Please try this in your activity and check..
@Override
public void onDestroy() {
super.onDestroy();
Runtime.getRuntime().gc();
}
The activity you're calling the finish()
method from is destroyed and all its resources are queued for garbage collection, because a reference to this activity becomes inaccessible. So, all memory that was used by this activity will be freed during next GC cycle.
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