'Possible to Force Garbage Collection in Android ? [duplicate]

in Android Running time Android Monitor will Show the Memory Usage. that Panel have a initiate Garbage CollectionButton while pressing that Button Memory will reduce. my question is programmatically initiate that Garbage initiation.Before CG and After CG



Solution 1:[1]

Runtime.getRuntime().gc();

This line of code does not guarantee that garbage collector will be called. But it usually is as far as I can see.

And actually you don't need it. You should ensure you have no leaks and let GC work on it's own.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Fedor