Since the garbage collector uses a Mark-Sweep algorithm:
The actual GC is done using a Mark-Sweep algorithm. This is done using a bitvector to track which objects are reachable initially marking root objects as reachable. Then the GC does a sweep over the objects in the heap in address order marking. For each reachable object it sweeps over it marks all objects reachable from that object as reachable. If the new object has a lower address it is added to a work queue. After the initial sweep the work queue is
So it will pass by every object that has a reference to the root and every other will be collected is there any case when putting a reference to null on an Activity is useful?
Putting on onDestroy
I assume that has no advantage correct?
What about putting them as null on onPause
(after validating isFinishing
) on "heavy" activities. Will it help the resources to get collected sooner?