Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 673
Natheem Yousuf Avatar asked Dec 22 '16 06:12

Natheem Yousuf


1 Answers

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.

like image 105
Fedor Avatar answered Nov 12 '22 19:11

Fedor