Reputation:
How to free inactive memory in Android? I have seen some applications that claim to free RAM programmatically. After having studied them I found they free inactive memory of the device. Are there any APIs to do this?
Upvotes: 15
Views: 20832
Reputation: 623
check this link
main code from it :
public void freeMemory(){
System.runFinalization();
Runtime.getRuntime().gc();
System.gc();
}
Upvotes: 24
Reputation: 345
call the garbage collector to free memory , best place to call it is onDestroy()
eg :
@Override
protected void onDestroy() {
System.gc();
super.onDestroy();
}
Upvotes: 6